summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess')
-rw-r--r--Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp4
-rw-r--r--Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp17
-rw-r--r--Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h3
-rw-r--r--Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in1
-rw-r--r--Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp19
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp5
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp5
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp54
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h46
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h77
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp10
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp8
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp19
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h2
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h1
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp84
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h66
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp4
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h3
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp15
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h1
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp28
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h4
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp54
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h8
-rw-r--r--Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp12
-rw-r--r--Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp59
-rw-r--r--Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h19
-rw-r--r--Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp46
-rw-r--r--Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h4
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp8
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp29
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h3
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp29
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h16
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm72
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm33
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm31
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp112
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h7
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.mm (renamed from Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp)73
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Plugin.cpp17
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Plugin.h26
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginController.h9
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp2
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp12
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginProxy.h6
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in13
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginView.cpp36
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginView.h11
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h51
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp41
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h5
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp4
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h3
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp8
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h12
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h7
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp128
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h11
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp4
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h4
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp324
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h69
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp16
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp15
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h12
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp21
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h4
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/efl/WebContextMenuClientEfl.cpp4
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp4
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp84
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm227
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm24
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm15
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp41
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h (renamed from Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h)16
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp3
-rw-r--r--Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp10
-rw-r--r--Source/WebKit2/WebProcess/WebPage/DrawingArea.h11
-rw-r--r--Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in2
-rw-r--r--Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp35
-rw-r--r--Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h7
-rw-r--r--Source/WebKit2/WebProcess/WebPage/FindController.cpp44
-rw-r--r--Source/WebKit2/WebProcess/WebPage/FindController.h6
-rw-r--r--Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h16
-rw-r--r--Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in3
-rw-r--r--Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp15
-rw-r--r--Source/WebKit2/WebProcess/WebPage/PageOverlay.h1
-rw-r--r--Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp7
-rw-r--r--Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp23
-rw-r--r--Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h8
-rw-r--r--Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp140
-rw-r--r--Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h64
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp12
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h2
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp5
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebContextMenu.h3
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebInspector.cpp34
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebInspector.h18
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in6
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebPage.cpp392
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebPage.h57
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebPage.messages.in24
-rw-r--r--Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h2
-rw-r--r--Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm44
-rw-r--r--Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp54
-rw-r--r--Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h5
-rw-r--r--Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h16
-rw-r--r--Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm160
-rw-r--r--Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm3
-rw-r--r--Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm32
-rw-r--r--Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm167
-rw-r--r--Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp168
-rw-r--r--Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h23
-rw-r--r--Source/WebKit2/WebProcess/WebProcess.cpp41
-rw-r--r--Source/WebKit2/WebProcess/WebProcess.h23
-rw-r--r--Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in7
-rw-r--r--Source/WebKit2/WebProcess/mac/WebProcessMac.mm39
-rw-r--r--Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm12
-rw-r--r--Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp5
-rw-r--r--Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp38
-rw-r--r--Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.cpp97
-rw-r--r--Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.h57
-rw-r--r--Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp115
-rw-r--r--Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h66
-rw-r--r--Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in26
131 files changed, 3300 insertions, 1233 deletions
diff --git a/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp b/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp
index be5421b43..da218087a 100644
--- a/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp
+++ b/Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp
@@ -35,7 +35,7 @@ namespace WebKit {
void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookieJarAcceptPolicy soupPolicy;
soupPolicy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
@@ -55,7 +55,7 @@ void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy
HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy()
{
- SoupCookieJar* cookieJar = WebCore::defaultCookieJar();
+ SoupCookieJar* cookieJar = WebCore::soupCookieJar();
SoupCookieJarAcceptPolicy soupPolicy;
HTTPCookieAcceptPolicy policy;
diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp
index 7e4a4e3c2..c5fc81a9e 100644
--- a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp
+++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.cpp
@@ -101,8 +101,6 @@ void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element)
void WebFullScreenManager::exitFullScreenForElement(WebCore::Element* element)
{
- ASSERT(element);
- ASSERT(m_element == element);
m_page->injectedBundleFullScreenClient().exitFullScreenForElement(m_page.get(), element);
}
@@ -113,7 +111,7 @@ void WebFullScreenManager::willEnterFullScreen()
m_element->document()->updateLayout();
m_page->forceRepaintWithoutCallback();
m_finalFrame = screenRectOfContents(m_element.get());
- m_page->send(Messages::WebFullScreenManagerProxy::BeganEnterFullScreen(m_initialFrame, m_finalFrame));
+ m_page->injectedBundleFullScreenClient().beganEnterFullScreen(m_page.get(), m_initialFrame, m_finalFrame);
}
void WebFullScreenManager::didEnterFullScreen()
@@ -127,7 +125,7 @@ void WebFullScreenManager::willExitFullScreen()
ASSERT(m_element);
m_finalFrame = screenRectOfContents(m_element.get());
m_element->document()->webkitWillExitFullScreenForElement(m_element.get());
- m_page->send(Messages::WebFullScreenManagerProxy::BeganExitFullScreen(m_finalFrame, m_initialFrame));
+ m_page->injectedBundleFullScreenClient().beganExitFullScreen(m_page.get(), m_finalFrame, m_initialFrame);
}
void WebFullScreenManager::didExitFullScreen()
@@ -142,6 +140,17 @@ void WebFullScreenManager::setAnimatingFullScreen(bool animating)
m_element->document()->setAnimatingFullScreen(animating);
}
+void WebFullScreenManager::requestExitFullScreen()
+{
+ ASSERT(m_element);
+ m_element->document()->webkitCancelFullScreen();
+}
+
+void WebFullScreenManager::close()
+{
+ m_page->injectedBundleFullScreenClient().closeFullScreen(m_page.get());
+}
+
} // namespace WebKit
#endif // ENABLE(FULLSCREEN_API)
diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h
index 9724d55e5..396a4adb1 100644
--- a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h
+++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.h
@@ -65,10 +65,13 @@ public:
WebCore::Element* element();
+ void close();
+
protected:
WebFullScreenManager(WebPage*);
void setAnimatingFullScreen(bool);
+ void requestExitFullScreen();
void didReceiveWebFullScreenManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
diff --git a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in
index d4ac9464d..239d33cbb 100644
--- a/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in
+++ b/Source/WebKit2/WebProcess/FullScreen/WebFullScreenManager.messages.in
@@ -22,6 +22,7 @@
#if ENABLE(FULLSCREEN_API)
messages -> WebFullScreenManager {
+ RequestExitFullScreen()
WillEnterFullScreen()
DidEnterFullScreen()
WillExitFullScreen()
diff --git a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp
index cee8e0bac..2b976763f 100644
--- a/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp
+++ b/Source/WebKit2/WebProcess/Geolocation/WebGeolocationManager.cpp
@@ -29,14 +29,11 @@
#include "WebGeolocationManagerProxyMessages.h"
#include "WebPage.h"
#include "WebProcess.h"
-
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
#include <WebCore/Geolocation.h>
#include <WebCore/GeolocationController.h>
#include <WebCore/GeolocationError.h>
#include <WebCore/GeolocationPosition.h>
#include <WebCore/Page.h>
-#endif
using namespace WebCore;
@@ -58,29 +55,25 @@ void WebGeolocationManager::didReceiveMessage(CoreIPC::Connection* connection, C
void WebGeolocationManager::registerWebPage(WebPage* page)
{
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
bool wasEmpty = m_pageSet.isEmpty();
m_pageSet.add(page);
if (wasEmpty)
m_process->connection()->send(Messages::WebGeolocationManagerProxy::StartUpdating(), 0);
-#endif
}
void WebGeolocationManager::unregisterWebPage(WebPage* page)
{
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
m_pageSet.remove(page);
if (m_pageSet.isEmpty())
m_process->connection()->send(Messages::WebGeolocationManagerProxy::StopUpdating(), 0);
-#endif
}
void WebGeolocationManager::didChangePosition(const WebGeolocationPosition::Data& data)
{
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
+#if ENABLE(GEOLOCATION)
RefPtr<GeolocationPosition> position = GeolocationPosition::create(data.timestamp, data.latitude, data.longitude, data.accuracy);
HashSet<WebPage*>::const_iterator it = m_pageSet.begin();
@@ -88,14 +81,14 @@ void WebGeolocationManager::didChangePosition(const WebGeolocationPosition::Data
for (; it != end; ++it) {
WebPage* page = *it;
if (page->corePage())
- page->corePage()->geolocationController()->positionChanged(position.get());
+ GeolocationController::from(page->corePage())->positionChanged(position.get());
}
-#endif
+#endif // ENABLE(GEOLOCATION)
}
void WebGeolocationManager::didFailToDeterminePosition()
{
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
+#if ENABLE(GEOLOCATION)
// FIXME: Add localized error string.
RefPtr<GeolocationError> error = GeolocationError::create(GeolocationError::PositionUnavailable, /* Localized error string */ String(""));
@@ -104,9 +97,9 @@ void WebGeolocationManager::didFailToDeterminePosition()
for (; it != end; ++it) {
WebPage* page = *it;
if (page->corePage())
- page->corePage()->geolocationController()->errorOccurred(error.get());
+ GeolocationController::from(page->corePage())->errorOccurred(error.get());
}
-#endif
+#endif // ENABLE(GEOLOCATION)
}
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
index 873931220..54128bfa2 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
@@ -240,3 +240,8 @@ bool WKBundleIsProcessingUserGesture(WKBundleRef)
{
return InjectedBundle::isProcessingUserGesture();
}
+
+void WKBundleSetPageVisibilityState(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, int state, bool isInitialState)
+{
+ toImpl(bundleRef)->setPageVisibilityState(toImpl(pageGroupRef), state, isInitialState);
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
index db32716c1..e40c898c7 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
@@ -44,6 +44,7 @@ namespace WebKit {
class InjectedBundle;
class InjectedBundleBackForwardList;
class InjectedBundleBackForwardListItem;
+class InjectedBundleDOMWindowExtension;
class InjectedBundleHitTestResult;
class InjectedBundleNavigationAction;
class InjectedBundleNodeHandle;
@@ -58,6 +59,7 @@ class WebPageGroupProxy;
WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem)
WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration)
+WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension)
WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp
index e9845e355..4b32b3481 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp
@@ -67,6 +67,11 @@ bool WKBundleBackForwardListItemIsTargetItem(WKBundleBackForwardListItemRef item
return toImpl(itemRef)->isTargetItem();
}
+bool WKBundleBackForwardListItemIsInPageCache(WKBundleBackForwardListItemRef itemRef)
+{
+ return toImpl(itemRef)->isInPageCache();
+}
+
WKArrayRef WKBundleBackForwardListItemCopyChildren(WKBundleBackForwardListItemRef itemRef)
{
return toAPI(toImpl(itemRef)->children().leakRef());
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h
index f256464e6..e9475ac1e 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h
@@ -43,6 +43,8 @@ WK_EXPORT WKStringRef WKBundleBackForwardListItemCopyTitle(WKBundleBackForwardLi
WK_EXPORT WKStringRef WKBundleBackForwardListItemCopyTarget(WKBundleBackForwardListItemRef item);
WK_EXPORT bool WKBundleBackForwardListItemIsTargetItem(WKBundleBackForwardListItemRef item);
+WK_EXPORT bool WKBundleBackForwardListItemIsInPageCache(WKBundleBackForwardListItemRef item);
+
WK_EXPORT WKArrayRef WKBundleBackForwardListItemCopyChildren(WKBundleBackForwardListItemRef item);
#ifdef __cplusplus
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp
new file mode 100644
index 000000000..6e5bd62a8
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * 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 "WKBundleDOMWindowExtension.h"
+
+#include "InjectedBundleDOMWindowExtension.h"
+#include "WKBundleAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKBundleDOMWindowExtensionGetTypeID()
+{
+ return toAPI(InjectedBundleDOMWindowExtension::APIType);
+}
+
+WKBundleDOMWindowExtensionRef WKBundleDOMWindowExtensionCreate(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
+{
+ RefPtr<InjectedBundleDOMWindowExtension> extension = InjectedBundleDOMWindowExtension::create(toImpl(frame), toImpl(world));
+ return toAPI(extension.release().leakRef());
+}
+
+WKBundleFrameRef WKBundleDOMWindowExtensionGetFrame(WKBundleDOMWindowExtensionRef extension)
+{
+ return toAPI(toImpl(extension)->frame());
+}
+
+WKBundleScriptWorldRef WKBundleDOMWindowExtensionGetScriptWorld(WKBundleDOMWindowExtensionRef extension)
+{
+ return toAPI(toImpl(extension)->world());
+}
+
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h
new file mode 100644
index 000000000..409a74289
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * 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 WKBundleDOMWindowExtension_h
+#define WKBundleDOMWindowExtension_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKBundleDOMWindowExtensionGetTypeID();
+
+WK_EXPORT WKBundleDOMWindowExtensionRef WKBundleDOMWindowExtensionCreate(WKBundleFrameRef frame, WKBundleScriptWorldRef world);
+
+WK_EXPORT WKBundleFrameRef WKBundleDOMWindowExtensionGetFrame(WKBundleDOMWindowExtensionRef extension);
+WK_EXPORT WKBundleScriptWorldRef WKBundleDOMWindowExtensionGetScriptWorld(WKBundleDOMWindowExtensionRef extension);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKBundleDOMWindowExtension_h */
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
index 4a9ee0554..c7fe682a6 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
@@ -54,7 +54,9 @@ WKTypeID WKBundlePageGetTypeID()
void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClient* wkClient)
{
+#if ENABLE(CONTEXT_MENUS)
toImpl(pageRef)->initializeInjectedBundleContextMenuClient(wkClient);
+#endif
}
void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClient* wkClient)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
index c75337acf..75608e6fe 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
@@ -26,6 +26,7 @@
#ifndef WKBundlePage_h
#define WKBundlePage_h
+#include <JavaScriptCore/JavaScript.h>
#include <WebKit2/WKBase.h>
#include <WebKit2/WKEvent.h>
#include <WebKit2/WKFindOptions.h>
@@ -101,35 +102,45 @@ typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef
typedef void (*WKBundlePageDidCancelClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
+typedef bool (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo);
+typedef void (*WKBundlePageGlobalObjectIsAvailableForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
+typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
+typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
+typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
struct WKBundlePageLoaderClient {
- int version;
- const void * clientInfo;
+ int version;
+ const void * clientInfo;
// Version 0.
- WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame;
- WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame;
- WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame;
- WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame;
- WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame;
- WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame;
- WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame;
- WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame;
- WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame;
- WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame;
- WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame;
- WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy;
- WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame;
- WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame;
- WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame;
- WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame;
- WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame;
- WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame;
+ WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame;
+ WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame;
+ WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame;
+ WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame;
+ WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame;
+ WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame;
+ WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame;
+ WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame;
+ WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame;
+ WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame;
+ WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame;
+ WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy;
+ WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame;
+ WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame;
+ WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame;
+ WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame;
+ WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame;
+ WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame;
// Version 1.
- WKBundlePageDidLayoutForFrameCallback didLayoutForFrame;
- WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback didNewFirstVisuallyNonEmptyLayout;
- WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame;
+ WKBundlePageDidLayoutForFrameCallback didLayoutForFrame;
+ WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback didNewFirstVisuallyNonEmptyLayout;
+ WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame;
+ WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem;
+ WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame;
+ WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject;
+ WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject;
+ WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension;
};
typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
@@ -272,20 +283,26 @@ typedef void (*WKBundlePageTextDidChangeInTextFieldCallback)(WKBundlePageRef pag
typedef void (*WKBundlePageTextDidChangeInTextAreaCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlTextAreaElementHandle, WKBundleFrameRef frame, const void* clientInfo);
typedef bool (*WKBundlePageShouldPerformActionInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKInputFieldActionType actionType, WKBundleFrameRef frame, const void* clientInfo);
typedef void (*WKBundlePageWillSubmitFormCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef* userData, const void* clientInfo);
+typedef void (*WKBundlePageWillSendSubmitEventCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, const void* clientInfo);
struct WKBundlePageFormClient {
int version;
const void * clientInfo;
+
+ // Version 0.
WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing;
WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing;
WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField;
WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea;
WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField;
WKBundlePageWillSubmitFormCallback willSubmitForm;
+
+ // Version 1.
+ WKBundlePageWillSendSubmitEventCallback willSendSubmitEvent;
};
typedef struct WKBundlePageFormClient WKBundlePageFormClient;
-enum { kWKBundlePageFormClientCurrentVersion = 0 };
+enum { kWKBundlePageFormClientCurrentVersion = 1 };
// ContextMenu client
typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo);
@@ -303,17 +320,27 @@ enum { kWKBundlePageContextMenuClientCurrentVersion = 0 };
typedef bool (*WKBundlePageSupportsFullScreen)(WKBundlePageRef page, WKFullScreenKeyboardRequestType requestType);
typedef void (*WKBundlePageEnterFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element);
typedef void (*WKBundlePageExitFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element);
+typedef void (*WKBundlePageBeganEnterFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame);
+typedef void (*WKBundlePageBeganExitFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame);
+typedef void (*WKBundlePageCloseFullScreen)(WKBundlePageRef page);
struct WKBundlePageFullScreenClient {
int version;
const void * clientInfo;
+
+ // Version 0:
WKBundlePageSupportsFullScreen supportsFullScreen;
WKBundlePageEnterFullScreenForElement enterFullScreenForElement;
WKBundlePageExitFullScreenForElement exitFullScreenForElement;
+
+ // Version 1:
+ WKBundlePageBeganEnterFullScreen beganEnterFullScreen;
+ WKBundlePageBeganExitFullScreen beganExitFullScreen;
+ WKBundlePageCloseFullScreen closeFullScreen;
};
typedef struct WKBundlePageFullScreenClient WKBundlePageFullScreenClient;
-enum { kWKBundlePageFullScreenClientCurrentVersion = 0 };
+enum { kWKBundlePageFullScreenClientCurrentVersion = 1 };
WK_EXPORT void WKBundlePageWillEnterFullScreen(WKBundlePageRef page);
WK_EXPORT void WKBundlePageDidEnterFullScreen(WKBundlePageRef page);
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
index b371f56a5..5848ec878 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
@@ -90,6 +90,8 @@ WK_EXPORT bool WKBundleIsProcessingUserGesture(WKBundleRef bundle);
WK_EXPORT void WKBundleSwitchNetworkLoaderToNewTestingSession(WKBundleRef bundle);
+WK_EXPORT void WKBundleSetPageVisibilityState(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, int state, bool isInitialState);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
index cebbb30c1..0c4295e61 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
@@ -67,12 +67,12 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node*
if (!node)
return 0;
- std::pair<DOMHandleCache::iterator, bool> result = domHandleCache().add(node, 0);
- if (!result.second)
- return PassRefPtr<InjectedBundleNodeHandle>(result.first->second);
+ DOMHandleCache::AddResult result = domHandleCache().add(node, 0);
+ if (!result.isNewEntry)
+ return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->second);
RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node);
- result.first->second = nodeHandle.get();
+ result.iterator->second = nodeHandle.get();
return nodeHandle.release();
}
@@ -114,7 +114,7 @@ IntRect InjectedBundleNodeHandle::elementBounds() const
IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced) const
{
- return m_node.get()->renderRect(isReplaced);
+ return m_node.get()->pixelSnappedRenderRect(isReplaced);
}
void InjectedBundleNodeHandle::setHTMLInputElementValueForUser(const String& value)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
index e94edfd34..1b74f0124 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
@@ -46,12 +46,12 @@ PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(Ran
if (!range)
return 0;
- std::pair<DOMHandleCache::iterator, bool> result = domHandleCache().add(range, 0);
- if (!result.second)
- return PassRefPtr<InjectedBundleRangeHandle>(result.first->second);
+ DOMHandleCache::AddResult result = domHandleCache().add(range, 0);
+ if (!result.isNewEntry)
+ return PassRefPtr<InjectedBundleRangeHandle>(result.iterator->second);
RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::create(range);
- result.first->second = rangeHandle.get();
+ result.iterator->second = rangeHandle.get();
return rangeHandle.release();
}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
index 2267d66a9..8e4f2a11d 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
@@ -54,6 +54,7 @@
#include <WebCore/JSDOMWindow.h>
#include <WebCore/Page.h>
#include <WebCore/PageGroup.h>
+#include <WebCore/PageVisibilityState.h>
#include <WebCore/PrintContext.h>
#include <WebCore/ResourceHandle.h>
#include <WebCore/ScriptController.h>
@@ -138,7 +139,8 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page
macro(WebKitUsesPageCachePreferenceKey, UsesPageCache, usesPageCache) \
macro(WebKitWebAudioEnabled, WebAudioEnabled, webAudioEnabled) \
macro(WebKitWebGLEnabled, WebGLEnabled, webGLEnabled) \
- macro(WebKitXSSAuditorEnabled, XSSAuditorEnabled, xssAuditorEnabled)
+ macro(WebKitXSSAuditorEnabled, XSSAuditorEnabled, xssAuditorEnabled) \
+ macro(WebKitShouldRespectImageOrientation, ShouldRespectImageOrientation, shouldRespectImageOrientation)
if (preference == "WebKitAcceleratedCompositingEnabled")
enabled = enabled && LayerTreeHost::supportsAcceleratedCompositing();
@@ -195,11 +197,11 @@ void InjectedBundle::setFrameFlatteningEnabled(WebPageGroupProxy* pageGroup, boo
void InjectedBundle::setGeoLocationPermission(WebPageGroupProxy* pageGroup, bool enabled)
{
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
+#if ENABLE(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
+ static_cast<GeolocationClientMock*>(GeolocationController::from(*iter)->client())->setPermission(enabled);
+#endif // ENABLE(GEOLOCATION)
}
void InjectedBundle::setJavaScriptCanAccessClipboard(WebPageGroupProxy* pageGroup, bool enabled)
@@ -456,4 +458,13 @@ void InjectedBundle::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC:
ASSERT_NOT_REACHED();
}
+void InjectedBundle::setPageVisibilityState(WebPageGroupProxy* pageGroup, int state, bool isInitialState)
+{
+#if ENABLE(PAGE_VISIBILITY_API)
+ const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages();
+ for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
+ (*iter)->setVisibilityState(static_cast<PageVisibilityState>(state), isInitialState);
+#endif
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
index 3bc660294..d6e255b44 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
@@ -156,6 +156,8 @@ public:
static bool isProcessingUserGesture();
+ void setPageVisibilityState(WebPageGroupProxy*, int state, bool isInitialState);
+
private:
InjectedBundle(const String&);
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h
index 6cd9ec682..da08fb7e7 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h
@@ -53,6 +53,7 @@ public:
const String& target() const { return m_item->target(); }
bool isTargetItem() const { return m_item->isTargetItem(); }
+ bool isInPageCache() const { return m_item->isInPageCache(); }
PassRefPtr<ImmutableArray> children() const;
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp
new file mode 100644
index 000000000..d448e84dc
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * 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 "InjectedBundleDOMWindowExtension.h"
+
+#include "InjectedBundleScriptWorld.h"
+#include "WebFrame.h"
+#include "WebFrameLoaderClient.h"
+#include <WebCore/DOMWindowExtension.h>
+#include <WebCore/Frame.h>
+#include <wtf/HashMap.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+typedef HashMap<WebCore::DOMWindowExtension*, InjectedBundleDOMWindowExtension*> ExtensionMap;
+static ExtensionMap& allExtensions()
+{
+ DEFINE_STATIC_LOCAL(ExtensionMap, map, ());
+ return map;
+}
+
+PassRefPtr<InjectedBundleDOMWindowExtension> InjectedBundleDOMWindowExtension::create(WebFrame* frame, InjectedBundleScriptWorld* world)
+{
+ return adoptRef(new InjectedBundleDOMWindowExtension(frame, world));
+}
+
+InjectedBundleDOMWindowExtension* InjectedBundleDOMWindowExtension::get(DOMWindowExtension* extension)
+{
+ ASSERT(allExtensions().contains(extension));
+ return allExtensions().get(extension);
+}
+
+InjectedBundleDOMWindowExtension::InjectedBundleDOMWindowExtension(WebFrame* frame, InjectedBundleScriptWorld* world)
+ : m_coreExtension(DOMWindowExtension::create(frame->coreFrame(), world->coreWorld()))
+{
+ allExtensions().add(m_coreExtension.get(), this);
+}
+
+InjectedBundleDOMWindowExtension::~InjectedBundleDOMWindowExtension()
+{
+ ASSERT(allExtensions().contains(m_coreExtension.get()));
+ allExtensions().remove(m_coreExtension.get());
+}
+
+WebFrame* InjectedBundleDOMWindowExtension::frame() const
+{
+ WebCore::Frame* frame = m_coreExtension->frame();
+ return frame ? static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame() : 0;
+}
+
+InjectedBundleScriptWorld* InjectedBundleDOMWindowExtension::world() const
+{
+ if (!m_world)
+ m_world = InjectedBundleScriptWorld::getOrCreate(m_coreExtension->world());
+
+ return m_world.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h
new file mode 100644
index 000000000..6ff96fc87
--- /dev/null
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * 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 InjectedBundleDOMWindowExtension_h
+#define InjectedBundleDOMWindowExtension_h
+
+#include "APIObject.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class DOMWindowExtension;
+
+}
+
+namespace WebKit {
+
+class InjectedBundleScriptWorld;
+class WebFrame;
+
+class InjectedBundleDOMWindowExtension : public APIObject {
+public:
+ static const Type APIType = TypeBundleDOMWindowExtension;
+
+ static PassRefPtr<InjectedBundleDOMWindowExtension> create(WebFrame*, InjectedBundleScriptWorld*);
+ static InjectedBundleDOMWindowExtension* get(WebCore::DOMWindowExtension*);
+
+ virtual ~InjectedBundleDOMWindowExtension();
+
+ WebFrame* frame() const;
+ InjectedBundleScriptWorld* world() const;
+
+private:
+ virtual Type type() const { return APIType; }
+
+ InjectedBundleDOMWindowExtension(WebFrame*, InjectedBundleScriptWorld*);
+
+ RefPtr<WebCore::DOMWindowExtension> m_coreExtension;
+ mutable RefPtr<InjectedBundleScriptWorld> m_world;
+};
+
+} // namespace WebKit
+
+#endif // InjectedBundleDOMWindowExtension_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp
index 9df00819d..3cd8dfaec 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp
@@ -24,6 +24,9 @@
*/
#include "config.h"
+
+#if ENABLE(CONTEXT_MENUS)
+
#include "InjectedBundlePageContextMenuClient.h"
#include "ImmutableArray.h"
@@ -75,3 +78,4 @@ bool InjectedBundlePageContextMenuClient::getCustomMenuFromDefaultItems(WebPage*
}
} // namespace WebKit
+#endif // ENABLE(CONTEXT_MENUS)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h
index 0d8ea5f83..6a81d0547 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.h
@@ -26,6 +26,8 @@
#ifndef InjectedBundlePageContextMenuClient_h
#define InjectedBundlePageContextMenuClient_h
+#if ENABLE(CONTEXT_MENUS)
+
#include "APIClient.h"
#include "WKBundlePage.h"
#include <wtf/Vector.h>
@@ -48,4 +50,5 @@ public:
} // namespace WebKit
+#endif // ENABLE(CONTEXT_MENUS)
#endif // InjectedBundlePageEditorClient_h
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
index 39924ec16..365430467 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp
@@ -83,6 +83,21 @@ bool InjectedBundlePageFormClient::shouldPerformActionInTextField(WebPage* page,
return m_client.shouldPerformActionInTextField(toAPI(page), toAPI(nodeHandle.get()), actionType, toAPI(frame), m_client.clientInfo);
}
+void InjectedBundlePageFormClient::willSendSubmitEvent(WebPage* page, HTMLFormElement* formElement, WebFrame* frame, WebFrame* sourceFrame, const Vector<std::pair<String, String> >& values)
+{
+ if (!m_client.willSendSubmitEvent)
+ return;
+
+ RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(formElement);
+
+ ImmutableDictionary::MapType map;
+ for (size_t i = 0; i < values.size(); ++i)
+ map.set(values[i].first, WebString::create(values[i].second));
+ RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
+
+ m_client.willSendSubmitEvent(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), m_client.clientInfo);
+}
+
void InjectedBundlePageFormClient::willSubmitForm(WebPage* page, HTMLFormElement* formElement, WebFrame* frame, WebFrame* sourceFrame, const Vector<std::pair<String, String> >& values, RefPtr<APIObject>& userData)
{
if (!m_client.willSubmitForm)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h
index 89369dfb2..455028b9f 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.h
@@ -53,6 +53,7 @@ public:
void textDidChangeInTextArea(WebPage*, WebCore::HTMLTextAreaElement*, WebFrame*);
bool shouldPerformActionInTextField(WebPage*, WebCore::HTMLInputElement*, WKInputFieldActionType, WebFrame*);
void willSubmitForm(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String> >&, RefPtr<APIObject>& userData);
+ void willSendSubmitEvent(WebPage*, WebCore::HTMLFormElement*, WebFrame*, WebFrame* sourceFrame, const Vector<std::pair<String, String> >&);
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp
index d8e986f7d..96b9a184f 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp
@@ -32,6 +32,8 @@
#include "InjectedBundleNodeHandle.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
+#include "WKSharedAPICast.h"
+#include "WebCoreArgumentCoders.h"
#include "WebFullScreenManagerProxyMessages.h"
#include "WebPage.h"
#include <WebCore/Element.h>
@@ -68,6 +70,32 @@ void InjectedBundlePageFullScreenClient::exitFullScreenForElement(WebPage *page,
page->send(Messages::WebFullScreenManagerProxy::ExitFullScreen());
}
+
+void InjectedBundlePageFullScreenClient::beganEnterFullScreen(WebPage *page, IntRect& initialFrame, IntRect& finalFrame)
+{
+ if (m_client.beganEnterFullScreen)
+ m_client.beganEnterFullScreen(toAPI(page), toAPI(initialFrame), toAPI(finalFrame));
+ else
+ page->send(Messages::WebFullScreenManagerProxy::BeganEnterFullScreen(initialFrame, finalFrame));
+}
+
+
+void InjectedBundlePageFullScreenClient::beganExitFullScreen(WebPage *page, IntRect& initialFrame, IntRect& finalFrame)
+{
+ if (m_client.beganExitFullScreen)
+ m_client.beganExitFullScreen(toAPI(page), toAPI(initialFrame), toAPI(finalFrame));
+ else
+ page->send(Messages::WebFullScreenManagerProxy::BeganExitFullScreen(initialFrame, finalFrame));
+}
+
+void InjectedBundlePageFullScreenClient::closeFullScreen(WebPage *page)
+{
+ if (m_client.closeFullScreen)
+ m_client.closeFullScreen(toAPI(page));
+ else
+ page->send(Messages::WebFullScreenManagerProxy::Close());
+}
+
} // namespace WebKit
#endif // ENABLE(FULLSCREEN_API)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h
index c45b21780..81ab3ce18 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.h
@@ -35,6 +35,7 @@
namespace WebCore {
class Element;
+class IntRect;
}
namespace WebKit {
@@ -46,6 +47,9 @@ public:
bool supportsFullScreen(WebPage*, bool withKeyboard);
void enterFullScreenForElement(WebPage*, WebCore::Element*);
void exitFullScreenForElement(WebPage*, WebCore::Element*);
+ void beganEnterFullScreen(WebPage*, WebCore::IntRect& initialFrame, WebCore::IntRect& finalFrame);
+ void beganExitFullScreen(WebPage*, WebCore::IntRect& initialFrame, WebCore::IntRect& finalFrame);
+ void closeFullScreen(WebPage*);
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp
index 24a3b818a..c42244522 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
#include "config.h"
#include "InjectedBundlePageLoaderClient.h"
+#include "InjectedBundleDOMWindowExtension.h"
#include "InjectedBundleScriptWorld.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
@@ -36,6 +37,18 @@ using namespace WebCore;
namespace WebKit {
+bool InjectedBundlePageLoaderClient::shouldGoToBackForwardListItem(WebPage* page, InjectedBundleBackForwardListItem* item, RefPtr<APIObject>& userData)
+{
+ if (!m_client.shouldGoToBackForwardListItem)
+ return true;
+
+ WKTypeRef userDataToPass = 0;
+ bool result = m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), &userDataToPass, m_client.clientInfo);
+ userData = adoptRef(toImpl(userDataToPass));
+
+ return result;
+}
+
void InjectedBundlePageLoaderClient::didStartProvisionalLoadForFrame(WebPage* page, WebFrame* frame, RefPtr<APIObject>& userData)
{
if (!m_client.didStartProvisionalLoadForFrame)
@@ -236,4 +249,43 @@ void InjectedBundlePageLoaderClient::didHandleOnloadEventsForFrame(WebPage* page
m_client.didHandleOnloadEventsForFrame(toAPI(page), toAPI(frame), m_client.clientInfo);
}
+void InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame(WebPage* page, WebFrame* frame, WebCore::DOMWrapperWorld* world)
+{
+ if (!m_client.globalObjectIsAvailableForFrame)
+ return;
+
+ RefPtr<InjectedBundleScriptWorld> injectedWorld = InjectedBundleScriptWorld::getOrCreate(world);
+ m_client.globalObjectIsAvailableForFrame(toAPI(page), toAPI(frame), toAPI(injectedWorld.get()), m_client.clientInfo);
+}
+
+void InjectedBundlePageLoaderClient::willDisconnectDOMWindowExtensionFromGlobalObject(WebPage* page, WebCore::DOMWindowExtension* coreExtension)
+{
+ if (!m_client.willDisconnectDOMWindowExtensionFromGlobalObject)
+ return;
+
+ RefPtr<InjectedBundleDOMWindowExtension> extension = InjectedBundleDOMWindowExtension::get(coreExtension);
+ ASSERT(extension);
+ m_client.willDisconnectDOMWindowExtensionFromGlobalObject(toAPI(page), toAPI(extension.get()), m_client.clientInfo);
+}
+
+void InjectedBundlePageLoaderClient::didReconnectDOMWindowExtensionToGlobalObject(WebPage* page, WebCore::DOMWindowExtension* coreExtension)
+{
+ if (!m_client.didReconnectDOMWindowExtensionToGlobalObject)
+ return;
+
+ RefPtr<InjectedBundleDOMWindowExtension> extension = InjectedBundleDOMWindowExtension::get(coreExtension);
+ ASSERT(extension);
+ m_client.didReconnectDOMWindowExtensionToGlobalObject(toAPI(page), toAPI(extension.get()), m_client.clientInfo);
+}
+
+void InjectedBundlePageLoaderClient::willDestroyGlobalObjectForDOMWindowExtension(WebPage* page, WebCore::DOMWindowExtension* coreExtension)
+{
+ if (!m_client.willDestroyGlobalObjectForDOMWindowExtension)
+ return;
+
+ RefPtr<InjectedBundleDOMWindowExtension> extension = InjectedBundleDOMWindowExtension::get(coreExtension);
+ ASSERT(extension);
+ m_client.willDestroyGlobalObjectForDOMWindowExtension(toAPI(page), toAPI(extension.get()), m_client.clientInfo);
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h
index 1cc41a681..1692697e6 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h
+++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h
@@ -33,6 +33,7 @@
#include <wtf/Forward.h>
namespace WebCore {
+class DOMWindowExtension;
class DOMWrapperWorld;
class ResourceError;
class ResourceRequest;
@@ -42,11 +43,13 @@ class ResourceResponse;
namespace WebKit {
class APIObject;
+class InjectedBundleBackForwardListItem;
class WebPage;
class WebFrame;
class InjectedBundlePageLoaderClient : public APIClient<WKBundlePageLoaderClient, kWKBundlePageLoaderClientCurrentVersion> {
public:
+ bool shouldGoToBackForwardListItem(WebPage*, InjectedBundleBackForwardListItem*, RefPtr<APIObject>& userData);
void didStartProvisionalLoadForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData);
void didReceiveServerRedirectForProvisionalLoadForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData);
void didFailProvisionalLoadWithErrorForFrame(WebPage*, WebFrame*, const WebCore::ResourceError&, RefPtr<APIObject>& userData);
@@ -70,6 +73,11 @@ public:
void didCancelClientRedirectForFrame(WebPage*, WebFrame*);
void willPerformClientRedirectForFrame(WebPage*, WebFrame*, const String& url, double delay, double date);
void didHandleOnloadEventsForFrame(WebPage*, WebFrame*);
+
+ void globalObjectIsAvailableForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld*);
+ void willDisconnectDOMWindowExtensionFromGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
+ void didReconnectDOMWindowExtensionToGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
+ void willDestroyGlobalObjectForDOMWindowExtension(WebPage*, WebCore::DOMWindowExtension*);
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp
index b9973ad17..c44bbbb86 100644
--- a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp
+++ b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp
@@ -41,7 +41,7 @@ bool InjectedBundle::load(APIObject* initializationUserData)
{
if (m_sandboxExtension) {
if (!m_sandboxExtension->consume()) {
- fprintf(stderr, "InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
+ WTFLogAlways("InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
return false;
}
@@ -50,30 +50,30 @@ bool InjectedBundle::load(APIObject* initializationUserData)
RetainPtr<CFStringRef> injectedBundlePathStr(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(m_path.characters()), m_path.length()));
if (!injectedBundlePathStr) {
- fprintf(stderr, "InjectedBundle::load failed - Could not create the path string.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not create the path string.\n");
return false;
}
RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(0, injectedBundlePathStr.get(), kCFURLPOSIXPathStyle, false));
if (!bundleURL) {
- fprintf(stderr, "InjectedBundle::load failed - Could not create the url from the path string.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not create the url from the path string.\n");
return false;
}
m_platformBundle = CFBundleCreate(0, bundleURL.get());
if (!m_platformBundle) {
- fprintf(stderr, "InjectedBundle::load failed - Could not create the bundle.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not create the bundle.\n");
return false;
}
if (!CFBundleLoadExecutable(m_platformBundle)) {
- fprintf(stderr, "InjectedBundle::load failed - Could not load the executable from the bundle.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not load the executable from the bundle.\n");
return false;
}
WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName(m_platformBundle, CFSTR("WKBundleInitialize")));
if (!initializeFunction) {
- fprintf(stderr, "InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
+ WTFLogAlways("InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
return false;
}
diff --git a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp
index 73e71fbc9..4edfe5a4e 100644
--- a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp
+++ b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,7 +41,7 @@ using namespace WebCore;
namespace WebKit {
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
static uint64_t generateRequestID()
{
static uint64_t uniqueRequestID = 1;
@@ -59,11 +59,12 @@ NotificationPermissionRequestManager::NotificationPermissionRequestManager(WebPa
{
}
-void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback)
-{
#if ENABLE(NOTIFICATIONS)
- if (permissionLevel(origin) != NotificationClient::PermissionNotAllowed) {
- callback->handleEvent();
+void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin, PassRefPtr<NotificationPermissionCallback> callback)
+{
+ NotificationClient::Permission permission = permissionLevel(origin);
+ if (permission != NotificationClient::PermissionNotAllowed) {
+ callback->handleEvent(Notification::permissionString(permission));
return;
}
@@ -72,21 +73,40 @@ void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin,
m_idToOriginMap.set(requestID, origin);
m_idToCallbackMap.set(requestID, callback);
m_page->send(Messages::WebPageProxy::RequestNotificationPermission(requestID, origin->toString()));
-#else
- UNUSED_PARAM(origin);
- UNUSED_PARAM(callback);
+}
#endif
+
+#if ENABLE(LEGACY_NOTIFICATIONS)
+void NotificationPermissionRequestManager::startRequest(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback)
+{
+ NotificationClient::Permission permission = permissionLevel(origin);
+ if (permission != NotificationClient::PermissionNotAllowed) {
+ callback->handleEvent();
+ return;
+ }
+
+ uint64_t requestID = generateRequestID();
+ m_originToIDMap.set(origin, requestID);
+ m_idToOriginMap.set(requestID, origin);
+ m_idToVoidCallbackMap.set(requestID, callback);
+ m_page->send(Messages::WebPageProxy::RequestNotificationPermission(requestID, origin->toString()));
}
+#endif
void NotificationPermissionRequestManager::cancelRequest(SecurityOrigin* origin)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
uint64_t id = m_originToIDMap.take(origin);
if (!id)
return;
m_idToOriginMap.remove(id);
+#if ENABLE(NOTIFICATIONS)
m_idToCallbackMap.remove(id);
+#endif
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ m_idToVoidCallbackMap.remove(id);
+#endif
#else
UNUSED_PARAM(origin);
#endif
@@ -94,7 +114,7 @@ void NotificationPermissionRequestManager::cancelRequest(SecurityOrigin* origin)
NotificationClient::Permission NotificationPermissionRequestManager::permissionLevel(SecurityOrigin* securityOrigin)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!m_page->corePage()->settings()->notificationsEnabled())
return NotificationClient::PermissionDenied;
@@ -107,15 +127,26 @@ NotificationClient::Permission NotificationPermissionRequestManager::permissionL
void NotificationPermissionRequestManager::didReceiveNotificationPermissionDecision(uint64_t requestID, bool allowed)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!isRequestIDValid(requestID))
return;
- RefPtr<VoidCallback> callback = m_idToCallbackMap.take(requestID);
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ RefPtr<VoidCallback> voidCallback = m_idToVoidCallbackMap.take(requestID);
+ if (voidCallback) {
+ voidCallback->handleEvent();
+ return;
+ }
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+ RefPtr<NotificationPermissionCallback> callback = m_idToCallbackMap.take(requestID);
if (!callback)
return;
- callback->handleEvent();
+ callback->handleEvent(Notification::permissionString(allowed ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied));
+#endif
+
#else
UNUSED_PARAM(requestID);
UNUSED_PARAM(allowed);
diff --git a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h
index 0397879ba..3b3799ae3 100644
--- a/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h
+++ b/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,7 @@
#define NotificationPermissionRequestManager_h
#include <WebCore/NotificationClient.h>
+#include <WebCore/NotificationPermissionCallback.h>
#include <WebCore/VoidCallback.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
@@ -45,8 +46,13 @@ class WebPage;
class NotificationPermissionRequestManager : public RefCounted<NotificationPermissionRequestManager> {
public:
static PassRefPtr<NotificationPermissionRequestManager> create(WebPage*);
-
+
+#if ENABLE(NOTIFICATIONS)
+ void startRequest(WebCore::SecurityOrigin*, PassRefPtr<WebCore::NotificationPermissionCallback>);
+#endif
+#if ENABLE(LEGACY_NOTIFICATIONS)
void startRequest(WebCore::SecurityOrigin*, PassRefPtr<WebCore::VoidCallback>);
+#endif
void cancelRequest(WebCore::SecurityOrigin*);
// Synchronous call to retrieve permission level for given security origin
@@ -56,8 +62,13 @@ public:
private:
NotificationPermissionRequestManager(WebPage*);
-
- HashMap<uint64_t, RefPtr<WebCore::VoidCallback> > m_idToCallbackMap;
+
+#if ENABLE(NOTIFICATIONS)
+ HashMap<uint64_t, RefPtr<WebCore::NotificationPermissionCallback> > m_idToCallbackMap;
+#endif
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ HashMap<uint64_t, RefPtr<WebCore::VoidCallback> > m_idToVoidCallbackMap;
+#endif
HashMap<RefPtr<WebCore::SecurityOrigin>, uint64_t> m_originToIDMap;
HashMap<uint64_t, RefPtr<WebCore::SecurityOrigin> > m_idToOriginMap;
diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
index 9e5cf9546..2d667ef5e 100644
--- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
+++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
@@ -29,7 +29,7 @@
#include "WebPage.h"
#include "WebProcess.h"
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#include "WebNotification.h"
#include "WebNotificationManagerProxyMessages.h"
#include "WebPageProxyMessages.h"
@@ -45,7 +45,7 @@ using namespace WebCore;
namespace WebKit {
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
static uint64_t generateNotificationID()
{
static uint64_t uniqueNotificationID = 1;
@@ -69,21 +69,21 @@ void WebNotificationManager::didReceiveMessage(CoreIPC::Connection* connection,
void WebNotificationManager::initialize(const HashMap<String, bool>& permissions)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
m_permissionsMap = permissions;
#endif
}
void WebNotificationManager::didUpdateNotificationDecision(const String& originString, bool allowed)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
m_permissionsMap.set(originString, allowed);
#endif
}
void WebNotificationManager::didRemoveNotificationDecisions(const Vector<String>& originStrings)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
size_t count = originStrings.size();
for (size_t i = 0; i < count; ++i)
m_permissionsMap.remove(originStrings[i]);
@@ -92,11 +92,12 @@ void WebNotificationManager::didRemoveNotificationDecisions(const Vector<String>
NotificationClient::Permission WebNotificationManager::policyForOrigin(WebCore::SecurityOrigin *origin) const
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!origin)
return NotificationClient::PermissionNotAllowed;
-
- HashMap<String, bool>::const_iterator it = m_permissionsMap.find(origin->toString());
+
+ ASSERT(!origin->isUnique());
+ HashMap<String, bool>::const_iterator it = m_permissionsMap.find(origin->toRawString());
if (it != m_permissionsMap.end())
return it->second ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied;
#endif
@@ -106,18 +107,22 @@ NotificationClient::Permission WebNotificationManager::policyForOrigin(WebCore::
bool WebNotificationManager::show(Notification* notification, WebPage* page)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!notification || !page->corePage()->settings()->notificationsEnabled())
- return true;
+ return false;
uint64_t notificationID = generateNotificationID();
m_notificationMap.set(notification, notificationID);
m_notificationIDMap.set(notificationID, notification);
- NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).first;
+ NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator;
it->second.append(notificationID);
-
- m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->contents().title, notification->contents().body, notification->iconURL().string(), notification->replaceId(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID());
+
+#if ENABLE(NOTIFICATIONS)
+ m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->tag(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID());
+#else
+ m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->replaceId(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID());
+#endif
return true;
#else
return false;
@@ -126,7 +131,7 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page)
void WebNotificationManager::cancel(Notification* notification, WebPage* page)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!notification || !page->corePage()->settings()->notificationsEnabled())
return;
@@ -140,7 +145,7 @@ void WebNotificationManager::cancel(Notification* notification, WebPage* page)
void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext* context, WebPage* page)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
NotificationContextMap::iterator it = m_notificationContextMap.find(context);
if (it == m_notificationContextMap.end())
return;
@@ -152,6 +157,7 @@ void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext*
RefPtr<Notification> notification = m_notificationIDMap.take(notificationIDs[i]);
if (!notification)
continue;
+ notification->finalize();
m_notificationMap.remove(notification);
}
@@ -161,7 +167,7 @@ void WebNotificationManager::clearNotifications(WebCore::ScriptExecutionContext*
void WebNotificationManager::didDestroyNotification(Notification* notification, WebPage* page)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
uint64_t notificationID = m_notificationMap.take(notification);
if (!notificationID)
return;
@@ -174,7 +180,7 @@ void WebNotificationManager::didDestroyNotification(Notification* notification,
void WebNotificationManager::didShowNotification(uint64_t notificationID)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!isNotificationIDValid(notificationID))
return;
@@ -188,7 +194,7 @@ void WebNotificationManager::didShowNotification(uint64_t notificationID)
void WebNotificationManager::didClickNotification(uint64_t notificationID)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (!isNotificationIDValid(notificationID))
return;
@@ -202,7 +208,7 @@ void WebNotificationManager::didClickNotification(uint64_t notificationID)
void WebNotificationManager::didCloseNotifications(const Vector<uint64_t>& notificationIDs)
{
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
size_t count = notificationIDs.size();
for (size_t i = 0; i < count; ++i) {
uint64_t notificationID = notificationIDs[i];
@@ -221,7 +227,7 @@ void WebNotificationManager::didCloseNotifications(const Vector<uint64_t>& notif
#endif
}
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
void WebNotificationManager::removeNotificationFromContextMap(uint64_t notificationID, Notification* notification)
{
// This is a helper function for managing the hash maps.
diff --git a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h
index 142767e31..2a18d44eb 100644
--- a/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h
+++ b/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h
@@ -78,13 +78,13 @@ private:
void didUpdateNotificationDecision(const String& originString, bool allowed);
void didRemoveNotificationDecisions(const Vector<String>& originStrings);
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
void removeNotificationFromContextMap(uint64_t notificationID, WebCore::Notification*);
#endif
WebProcess* m_process;
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
typedef HashMap<RefPtr<WebCore::Notification>, uint64_t> NotificationMap;
NotificationMap m_notificationMap;
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
index 01e73f95f..2efa0b891 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
@@ -102,7 +102,7 @@ JSObject* NPRuntimeObjectMap::getOrCreateJSObject(JSGlobalObject* globalObject,
return jsNPObject;
JSNPObject* jsNPObject = JSNPObject::create(globalObject, this, npObject);
- m_jsNPObjects.set(npObject, JSC::PassWeak<JSNPObject>(globalObject->globalData(), jsNPObject, this, npObject));
+ m_jsNPObjects.set(npObject, JSC::PassWeak<JSNPObject>(jsNPObject, this, npObject));
return jsNPObject;
}
@@ -290,11 +290,13 @@ void NPRuntimeObjectMap::addToInvalidationQueue(NPObject* npObject)
void NPRuntimeObjectMap::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
+ JSNPObject* object = jsCast<JSNPObject*>(asObject(handle.get()));
+
HashMap<NPObject*, JSC::Weak<JSNPObject> >::iterator found = m_jsNPObjects.find(static_cast<NPObject*>(context));
ASSERT(found != m_jsNPObjects.end());
- ASSERT_UNUSED(handle, asObject(handle.get()) == found->second);
- JSNPObject* object = found->second.get();
+ ASSERT(found->second.was(object));
m_jsNPObjects.remove(found);
+
addToInvalidationQueue(object->leakNPObject());
}
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index bdc6e9de9..fcd31f13b 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -417,9 +417,6 @@ static const unsigned WKNVAllowedToEnterSandbox = 74658;
// WKNVSandboxFunctions = 74659 is defined in NetscapeSandboxFunctions.h
-// The Core Animation render server port.
-static const unsigned WKNVCALayerRenderServerPort = 71879;
-
#endif
static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
@@ -551,23 +548,9 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
break;
case NPNVToolkit: {
-#if PLATFORM(GTK)
- *reinterpret_cast<uint32_t*>(value) = 2;
-#else
- const uint32_t expectedGTKToolKitVersion = 2;
-
- // Set the expected GTK version if we know that this plugin needs it or if the plugin call us
- // with a null instance. The latter is the case with NSPluginWrapper plugins.
- bool requiresGTKToolKitVersion;
- if (!npp)
- requiresGTKToolKitVersion = true;
- else {
- RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
- requiresGTKToolKitVersion = plugin->quirks().contains(PluginQuirks::RequiresGTKToolKit);
- }
-
- *reinterpret_cast<uint32_t*>(value) = requiresGTKToolKitVersion ? expectedGTKToolKitVersion : 0;
-#endif
+ // Gtk based plugins need to be assured about the toolkit version.
+ const uint32_t expectedGtkToolKitVersion = 2;
+ *reinterpret_cast<uint32_t*>(value) = expectedGtkToolKitVersion;
break;
}
@@ -706,12 +689,6 @@ static void NPN_ReleaseObject(NPObject *npObject)
static bool NPN_Invoke(NPP npp, NPObject *npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
- if (RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp)) {
- bool returnValue;
- if (plugin->tryToShortCircuitInvoke(npObject, methodName, arguments, argumentCount, returnValue, *result))
- return returnValue;
- }
-
if (npObject->_class->invoke)
return npObject->_class->invoke(npObject, methodName, arguments, argumentCount, result);
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h
index 49a7f3a9d..583df9724 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h
@@ -30,6 +30,9 @@
namespace WebKit {
+// The Core Animation render server port.
+static const unsigned WKNVCALayerRenderServerPort = 71879;
+
NPNetscapeFuncs* netscapeBrowserFuncs();
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 1f09dc408..b63c73a4e 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -35,6 +35,8 @@
#include <WebCore/HTTPHeaderMap.h>
#include <WebCore/IntRect.h>
#include <WebCore/KURL.h>
+#include <runtime/JSObject.h>
+#include <runtime/ScopeChain.h>
#include <utility>
#include <wtf/text/CString.h>
@@ -66,12 +68,13 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
#endif
, m_isTransparent(false)
, m_inNPPNew(false)
- , m_loadManually(false)
+ , m_shouldUseManualLoader(false)
, m_nextTimerID(0)
#if PLATFORM(MAC)
, m_drawingModel(static_cast<NPDrawingModel>(-1))
, m_eventModel(static_cast<NPEventModel>(-1))
, m_pluginReturnsNonretainedLayer(!m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsRetainedCoreAnimationLayer))
+ , m_layerHostingMode(LayerHostingModeDefault)
, m_currentMouseEvent(0)
, m_pluginHasFocus(false)
, m_windowHasFocus(false)
@@ -86,6 +89,9 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
#elif PLUGIN_ARCHITECTURE(X11)
, m_drawable(0)
, m_pluginDisplay(0)
+#if PLATFORM(GTK)
+ , m_platformPluginWidget(0)
+#endif
#endif
{
m_npp.ndata = this;
@@ -257,11 +263,6 @@ NPObject* NetscapePlugin::pluginElementNPObject()
return controller()->pluginElementNPObject();
}
-bool NetscapePlugin::tryToShortCircuitInvoke(NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result)
-{
- return controller()->tryToShortCircuitInvoke(npObject, methodName, arguments, argumentCount, returnValue, result);
-}
-
void NetscapePlugin::cancelStreamLoad(NetscapePluginStream* pluginStream)
{
if (pluginStream == m_manualStream) {
@@ -545,9 +546,9 @@ bool NetscapePlugin::allowPopups() const
bool NetscapePlugin::initialize(const Parameters& parameters)
{
- uint16_t mode = parameters.loadManually ? NP_FULL : NP_EMBED;
+ uint16_t mode = parameters.isFullFramePlugin ? NP_FULL : NP_EMBED;
- m_loadManually = parameters.loadManually;
+ m_shouldUseManualLoader = parameters.shouldUseManualLoader;
CString mimeTypeCString = parameters.mimeType.utf8();
@@ -584,6 +585,8 @@ bool NetscapePlugin::initialize(const Parameters& parameters)
}
}
}
+
+ m_layerHostingMode = parameters.layerHostingMode;
#endif
NetscapePlugin* previousNPPNewPlugin = currentNPPNewPlugin;
@@ -611,7 +614,7 @@ bool NetscapePlugin::initialize(const Parameters& parameters)
}
// Load the src URL if needed.
- if (!parameters.loadManually && !parameters.url.isEmpty() && shouldLoadSrcURL())
+ if (!parameters.shouldUseManualLoader && !parameters.url.isEmpty() && shouldLoadSrcURL())
loadURL("GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector<uint8_t>(), false, 0);
return true;
@@ -787,7 +790,7 @@ void NetscapePlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uin
const String& mimeType, const String& headers, const String& /* suggestedFileName */)
{
ASSERT(m_isStarted);
- ASSERT(m_loadManually);
+ ASSERT(m_shouldUseManualLoader);
ASSERT(!m_manualStream);
m_manualStream = NetscapePluginStream::create(this, 0, responseURL.string(), false, 0);
@@ -797,7 +800,7 @@ void NetscapePlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uin
void NetscapePlugin::manualStreamDidReceiveData(const char* bytes, int length)
{
ASSERT(m_isStarted);
- ASSERT(m_loadManually);
+ ASSERT(m_shouldUseManualLoader);
ASSERT(m_manualStream);
m_manualStream->didReceiveData(bytes, length);
@@ -806,7 +809,7 @@ void NetscapePlugin::manualStreamDidReceiveData(const char* bytes, int length)
void NetscapePlugin::manualStreamDidFinishLoading()
{
ASSERT(m_isStarted);
- ASSERT(m_loadManually);
+ ASSERT(m_shouldUseManualLoader);
ASSERT(m_manualStream);
m_manualStream->didFinishLoading();
@@ -815,7 +818,7 @@ void NetscapePlugin::manualStreamDidFinishLoading()
void NetscapePlugin::manualStreamDidFail(bool wasCancelled)
{
ASSERT(m_isStarted);
- ASSERT(m_loadManually);
+ ASSERT(m_shouldUseManualLoader);
if (!m_manualStream)
return;
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index adad2d015..660b68540 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -101,8 +101,6 @@ public:
NPObject* windowScriptNPObject();
NPObject* pluginElementNPObject();
- bool tryToShortCircuitInvoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result);
-
void cancelStreamLoad(NetscapePluginStream*);
void removePluginStream(NetscapePluginStream*);
@@ -207,9 +205,12 @@ private:
virtual uint64_t pluginComplexTextInputIdentifier() const;
virtual void sendComplexTextInput(const String& textInput);
+ virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
void pluginFocusOrWindowFocusChanged();
void setComplexTextInputEnabled(bool);
+
+ void updatePluginLayer();
#endif
virtual void contentsScaleFactorChanged(float);
@@ -233,6 +234,11 @@ private:
void scheduleWindowedGeometryUpdate();
#endif
+#if PLUGIN_ARCHITECTURE(X11)
+ bool platformPostInitializeWindowed(bool needsXEmbed, uint64_t windowID);
+ bool platformPostInitializeWindowless();
+#endif
+
uint64_t m_nextRequestID;
typedef HashMap<uint64_t, std::pair<String, void*> > PendingURLNotifyMap;
@@ -262,7 +268,7 @@ private:
bool m_isWindowed;
bool m_isTransparent;
bool m_inNPPNew;
- bool m_loadManually;
+ bool m_shouldUseManualLoader;
RefPtr<NetscapePluginStream> m_manualStream;
Vector<bool, 8> m_popupEnabledStates;
@@ -303,6 +309,7 @@ private:
RetainPtr<PlatformLayer> m_pluginLayer;
bool m_pluginReturnsNonretainedLayer;
+ LayerHostingMode m_layerHostingMode;
NPCocoaEvent* m_currentMouseEvent;
@@ -341,6 +348,9 @@ private:
#elif PLUGIN_ARCHITECTURE(X11)
Pixmap m_drawable;
Display* m_pluginDisplay;
+#if PLATFORM(GTK)
+ GtkWidget* m_platformPluginWidget;
+#endif
public: // Need to call it in the NPN_GetValue browser callback.
static Display* x11HostDisplay();
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
index c8d53819f..d01134501 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
@@ -26,6 +26,7 @@
#import "config.h"
#import "NetscapePlugin.h"
+#import "NetscapeBrowserFuncs.h"
#import "PluginController.h"
#import "WebEvent.h"
#import <Carbon/Carbon.h>
@@ -167,6 +168,11 @@ NPError NetscapePlugin::popUpContextMenu(NPMenu* npMenu)
mach_port_t NetscapePlugin::compositingRenderServerPort()
{
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+ if (m_layerHostingMode == LayerHostingModeInWindowServer)
+ return MACH_PORT_NULL;
+#endif
+
return controller()->compositingRenderServerPort();
}
@@ -219,27 +225,7 @@ bool NetscapePlugin::platformPostInitialize()
return false;
#endif
- if (m_drawingModel == NPDrawingModelCoreAnimation) {
- void* value = 0;
- // Get the Core Animation layer.
- if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) {
- ASSERT(!m_pluginLayer);
-
- // The original Core Animation drawing model required that plug-ins pass a retained layer
- // to the browser, which the browser would then adopt. However, the final spec changed this
- // (See https://wiki.mozilla.org/NPAPI:CoreAnimationDrawingModel for more information)
- // after a version of WebKit1 with the original implementation had shipped, but that now means
- // that any plug-ins that expect the WebKit1 behavior would leak the CALayer.
- // For plug-ins that we know return retained layers, we have the ReturnsRetainedCoreAnimationLayer
- // plug-in quirk. Plug-ins can also check for whether the browser expects a non-retained layer to
- // be returned by using NPN_GetValue and pass the WKNVExpectsNonretainedLayer parameter.
- // https://bugs.webkit.org/show_bug.cgi?id=58282 describes the bug where WebKit expects retained layers.
- if (m_pluginReturnsNonretainedLayer)
- m_pluginLayer = reinterpret_cast<CALayer *>(value);
- else
- m_pluginLayer.adoptNS(reinterpret_cast<CALayer *>(value));
- }
- }
+ updatePluginLayer();
#ifndef NP_NO_CARBON
if (m_eventModel == NPEventModelCarbon) {
@@ -1022,6 +1008,19 @@ void NetscapePlugin::sendComplexTextInput(const String& textInput)
}
}
+void NetscapePlugin::setLayerHostingMode(LayerHostingMode layerHostingMode)
+{
+ m_layerHostingMode = layerHostingMode;
+
+ // Tell the plug-in about the new compositing render server port. If it returns OK we'll ask it again for a new layer.
+ mach_port_t port = NetscapePlugin::compositingRenderServerPort();
+ if (NPP_SetValue(static_cast<NPNVariable>(WKNVCALayerRenderServerPort), &port) != NPERR_NO_ERROR)
+ return;
+
+ m_pluginLayer = nullptr;
+ updatePluginLayer();
+}
+
void NetscapePlugin::pluginFocusOrWindowFocusChanged()
{
bool pluginHasFocusAndWindowHasFocus = m_pluginHasFocus && m_windowHasFocus;
@@ -1056,6 +1055,37 @@ PlatformLayer* NetscapePlugin::pluginLayer()
return static_cast<PlatformLayer*>(m_pluginLayer.get());
}
+void NetscapePlugin::updatePluginLayer()
+{
+ if (m_drawingModel != NPDrawingModelCoreAnimation)
+ return;
+
+ void* value = 0;
+
+ // Get the Core Animation layer.
+ if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) != NPERR_NO_ERROR)
+ return;
+
+ if (!value)
+ return;
+
+ ASSERT(!m_pluginLayer);
+
+ // The original Core Animation drawing model required that plug-ins pass a retained layer
+ // to the browser, which the browser would then adopt. However, the final spec changed this
+ // (See https://wiki.mozilla.org/NPAPI:CoreAnimationDrawingModel for more information)
+ // after a version of WebKit1 with the original implementation had shipped, but that now means
+ // that any plug-ins that expect the WebKit1 behavior would leak the CALayer.
+ // For plug-ins that we know return retained layers, we have the ReturnsRetainedCoreAnimationLayer
+ // plug-in quirk. Plug-ins can also check for whether the browser expects a non-retained layer to
+ // be returned by using NPN_GetValue and pass the WKNVExpectsNonretainedLayer parameter.
+ // https://bugs.webkit.org/show_bug.cgi?id=58282 describes the bug where WebKit expects retained layers.
+ if (m_pluginReturnsNonretainedLayer)
+ m_pluginLayer = reinterpret_cast<CALayer *>(value);
+ else
+ m_pluginLayer.adoptNS(reinterpret_cast<CALayer *>(value));
+}
+
#ifndef NP_NO_CARBON
void NetscapePlugin::nullEventTimerFired()
{
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm
index 43aea5faa..f2386c479 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm
@@ -29,6 +29,7 @@
#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
#import "PluginProcess.h"
+#import "NetscapePluginModule.h"
#import "WebKitSystemInterface.h"
#import <WebCore/FileSystem.h>
#import <WebCore/SoftLinking.h>
@@ -59,22 +60,22 @@ static bool enteredSandbox;
static CString readSandboxProfile()
{
- RetainPtr<CFURLRef> profileURL(AdoptCF, CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("plugin"), CFSTR("sb"), 0));
+ RetainPtr<CFURLRef> profileURL(AdoptCF, CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("com.apple.WebKit.PluginProcess"), CFSTR("sb"), 0));
char profilePath[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(profileURL.get(), false, reinterpret_cast<UInt8*>(profilePath), sizeof(profilePath))) {
- fprintf(stderr, "Could not get file system representation of plug-in sandbox URL\n");
+ WTFLogAlways("Could not get file system representation of plug-in sandbox URL\n");
return CString();
}
FILE *file = fopen(profilePath, "r");
if (!file) {
- fprintf(stderr, "Could not open plug-in sandbox file '%s'\n", profilePath);
+ WTFLogAlways("Could not open plug-in sandbox file '%s'\n", profilePath);
return CString();
}
struct stat fileInfo;
if (stat(profilePath, &fileInfo)) {
- fprintf(stderr, "Could not get plug-in sandbox file size '%s'\n", profilePath);
+ WTFLogAlways("Could not get plug-in sandbox file size '%s'\n", profilePath);
return CString();
}
@@ -82,7 +83,7 @@ static CString readSandboxProfile()
CString result = CString::newUninitialized(fileInfo.st_size, characterBuffer);
if (1 != fread(characterBuffer, fileInfo.st_size, 1, file)) {
- fprintf(stderr, "Could not read plug-in sandbox file '%s'\n", profilePath);
+ WTFLogAlways("Could not read plug-in sandbox file '%s'\n", profilePath);
return CString();
}
@@ -100,6 +101,19 @@ NPError WKN_EnterSandbox(const char* readOnlyPaths[], const char* readWritePaths
if (profile.isNull())
exit(EX_NOPERM);
+#if !defined(BUILDING_ON_LION)
+ // Use private temporary and cache directories.
+ String systemDirectorySuffix = "com.apple.WebKit.PluginProcess+" + PluginProcess::shared().netscapePluginModule()->module()->bundleIdentifier();
+ setenv("DIRHELPER_USER_DIR_SUFFIX", fileSystemRepresentation(systemDirectorySuffix).data(), 0);
+ char temporaryDirectory[PATH_MAX];
+ if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
+ WTFLogAlways("PluginProcess: couldn't retrieve private temporary directory path: %d\n", errno);
+ exit(EX_NOPERM);
+ }
+ setenv("TMPDIR", temporaryDirectory, 1);
+#endif
+
+
Vector<const char*> extendedReadOnlyPaths;
if (readOnlyPaths) {
for (unsigned i = 0; readOnlyPaths[i]; ++i)
@@ -122,15 +136,12 @@ NPError WKN_EnterSandbox(const char* readOnlyPaths[], const char* readWritePaths
extendedReadWritePaths.append(readWritePaths[i]);
}
- // FIXME: <rdar://problem/10785457> Use a custom temporary directory.
char darwinUserTempDirectory[PATH_MAX];
if (confstr(_CS_DARWIN_USER_TEMP_DIR, darwinUserTempDirectory, PATH_MAX) > 0)
extendedReadWritePaths.append(darwinUserTempDirectory);
- // FIXME: <rdar://problem/10792047> Use a custom cache directory.
char darwinUserCacheDirectory[PATH_MAX];
- size_t darwinUserCachePathSize = confstr(_CS_DARWIN_USER_CACHE_DIR, darwinUserCacheDirectory, PATH_MAX);
- if (darwinUserCachePathSize > 0)
+ if (confstr(_CS_DARWIN_USER_CACHE_DIR, darwinUserCacheDirectory, PATH_MAX) > 0)
extendedReadWritePaths.append(darwinUserCacheDirectory);
RetainPtr<CFStringRef> cachePath(AdoptCF, WKCopyFoundationCacheDirectory());
@@ -145,12 +156,12 @@ NPError WKN_EnterSandbox(const char* readOnlyPaths[], const char* readWritePaths
const char* sandboxParameters[] = { "HOME_DIR", homeDirectory, 0, 0 };
if (!WKEnterPluginSandbox(profile.data(), sandboxParameters, extendedReadOnlyPaths.data(), extendedReadWritePaths.data())) {
- fprintf(stderr, "Couldn't initialize sandbox profile\n");
+ WTFLogAlways("Couldn't initialize sandbox profile\n");
exit(EX_NOPERM);
}
if (noErr != WKEnableSandboxStyleFileQuarantine()) {
- fprintf(stderr, "Couldn't enable file quarantine\n");
+ WTFLogAlways("Couldn't enable file quarantine\n");
exit(EX_NOPERM);
}
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
index 49385d9d9..844861299 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm
@@ -29,22 +29,29 @@
#if ENABLE(PLUGIN_PROCESS)
#import "PluginController.h"
+#import "PluginControllerProxyMessages.h"
+#import "PluginProcessConnection.h"
#import <WebKitSystemInterface.h>
namespace WebKit {
+static void makeRenderLayer(CALayer *pluginLayer, uint32_t layerHostingContextID)
+{
+ CALayer *renderLayer = WKMakeRenderLayer(layerHostingContextID);
+ [renderLayer setFrame:[pluginLayer bounds]];
+ [renderLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
+ [pluginLayer setSublayers:[NSArray arrayWithObject:renderLayer]];
+}
+
PlatformLayer* PluginProxy::pluginLayer()
{
if (!m_pluginLayer && m_remoteLayerClientID) {
- CALayer *renderLayer = WKMakeRenderLayer(m_remoteLayerClientID);
-
// Create a layer with flipped geometry and add the real plug-in layer as a sublayer
// so the coordinate system will match the event coordinate system.
m_pluginLayer.adoptNS([[CALayer alloc] init]);
[m_pluginLayer.get() setGeometryFlipped:YES];
-
- [renderLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
- [m_pluginLayer.get() addSublayer:renderLayer];
+
+ makeRenderLayer(m_pluginLayer.get(), m_remoteLayerClientID);
}
return m_pluginLayer.get();
@@ -65,6 +72,20 @@ void PluginProxy::setComplexTextInputState(uint64_t complexTextInputState)
controller()->setComplexTextInputState(static_cast<PluginComplexTextInputState>(complexTextInputState));
}
+void PluginProxy::setLayerHostingMode(LayerHostingMode layerHostingMode)
+{
+ m_connection->connection()->send(Messages::PluginControllerProxy::SetLayerHostingMode(layerHostingMode), m_pluginInstanceID);
+}
+
+void PluginProxy::setLayerHostingContextID(uint32_t layerHostingContextID)
+{
+ ASSERT(m_pluginLayer.get());
+
+ m_remoteLayerClientID = layerHostingContextID;
+ makeRenderLayer(m_pluginLayer.get(), m_remoteLayerClientID);
+}
+
+
} // namespace WebKit
#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
index a1c2a31a2..6564fd15f 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
@@ -29,6 +29,7 @@
#include "NetscapePlugin.h"
+#include "PluginController.h"
#include "WebEvent.h"
#include <WebCore/GraphicsContext.h>
#include <WebCore/NotImplemented.h>
@@ -39,6 +40,10 @@
#include "PlatformContextCairo.h"
#include "RefPtrCairo.h"
#include <cairo/cairo-xlib.h>
+#include <gtk/gtk.h>
+#ifndef GTK_API_VERSION_2
+#include <gtk/gtkx.h>
+#endif
#include <gdk/gdkx.h>
#include <WebCore/GtkVersioning.h>
#endif
@@ -144,26 +149,65 @@ Display* NetscapePlugin::x11HostDisplay()
#endif
}
-bool NetscapePlugin::platformPostInitialize()
-{
#if PLATFORM(GTK)
- if (moduleMixesGtkSymbols(m_pluginModule->module()))
- return false;
+static gboolean socketPlugRemovedCallback(GtkSocket*)
+{
+ // Default action is to destroy the GtkSocket, so we just return TRUE here
+ // to be able to reuse the socket. For some obscure reason, newer versions
+ // of flash plugin remove the plug from the socket, probably because the plug
+ // created by the plugin is re-parented.
+ return TRUE;
+}
#endif
- if (m_isWindowed)
+bool NetscapePlugin::platformPostInitializeWindowed(bool needsXEmbed, uint64_t windowID)
+{
+ m_npWindow.type = NPWindowTypeWindow;
+ if (!needsXEmbed) {
+ notImplemented();
return false;
+ }
- if (!(m_pluginDisplay = getPluginDisplay()))
- return false;
+ Display* display = x11HostDisplay();
- NPSetWindowCallbackStruct* callbackStruct = new NPSetWindowCallbackStruct;
- callbackStruct->type = 0;
+#if PLATFORM(GTK)
+ // It seems flash needs the socket to be in the same process,
+ // I guess it uses gdk_window_lookup(), so we create a new socket here
+ // containing a plug with the UI process socket embedded.
+ m_platformPluginWidget = gtk_plug_new(static_cast<Window>(windowID));
+ GtkWidget* socket = gtk_socket_new();
+ g_signal_connect(socket, "plug-removed", G_CALLBACK(socketPlugRemovedCallback), 0);
+ gtk_container_add(GTK_CONTAINER(m_platformPluginWidget), socket);
+ gtk_widget_show(socket);
+ gtk_widget_show(m_platformPluginWidget);
+
+ m_npWindow.window = GINT_TO_POINTER(gtk_socket_get_id(GTK_SOCKET(socket)));
+ GdkWindow* window = gtk_widget_get_window(socket);
+ NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info);
+ callbackStruct->display = GDK_WINDOW_XDISPLAY(window);
+ callbackStruct->visual = GDK_VISUAL_XVISUAL(gdk_window_get_visual(window));
+ callbackStruct->depth = gdk_visual_get_depth(gdk_window_get_visual(window));
+ callbackStruct->colormap = XCreateColormap(display, GDK_ROOT_WINDOW(), callbackStruct->visual, AllocNone);
+#endif
+
+ XFlush(display);
+
+ callSetWindow();
+
+ return true;
+}
+
+bool NetscapePlugin::platformPostInitializeWindowless()
+{
Display* display = x11HostDisplay();
+ m_npWindow.type = NPWindowTypeDrawable;
+ m_npWindow.window = 0;
+
int depth = displayDepth();
#if PLATFORM(QT)
ASSERT(depth == 16 || depth == 24 || depth == 32);
#endif
+ NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info);
callbackStruct->display = display;
callbackStruct->depth = depth;
@@ -182,15 +226,45 @@ bool NetscapePlugin::platformPostInitialize()
callbackStruct->visual = visual;
callbackStruct->colormap = XCreateColormap(display, rootWindowID(), visual, AllocNone);
- m_npWindow.type = NPWindowTypeDrawable;
- m_npWindow.window = 0;
- m_npWindow.ws_info = callbackStruct;
-
callSetWindow();
return true;
}
+bool NetscapePlugin::platformPostInitialize()
+{
+#if PLATFORM(GTK)
+ if (moduleMixesGtkSymbols(m_pluginModule->module()))
+ return false;
+#endif
+
+ uint64_t windowID = 0;
+ bool needsXEmbed = false;
+ if (m_isWindowed) {
+ NPP_GetValue(NPPVpluginNeedsXEmbed, &needsXEmbed);
+ if (needsXEmbed) {
+ windowID = controller()->createPluginContainer();
+ if (!windowID)
+ return false;
+ } else {
+ notImplemented();
+ return false;
+ }
+ }
+
+ if (!(m_pluginDisplay = getPluginDisplay()))
+ return false;
+
+ NPSetWindowCallbackStruct* callbackStruct = new NPSetWindowCallbackStruct;
+ callbackStruct->type = 0;
+ m_npWindow.ws_info = callbackStruct;
+
+ if (m_isWindowed)
+ return platformPostInitializeWindowed(needsXEmbed, windowID);
+
+ return platformPostInitializeWindowless();
+}
+
void NetscapePlugin::platformDestroy()
{
NPSetWindowCallbackStruct* callbackStruct = static_cast<NPSetWindowCallbackStruct*>(m_npWindow.ws_info);
@@ -213,7 +287,13 @@ bool NetscapePlugin::platformInvalidate(const IntRect&)
void NetscapePlugin::platformGeometryDidChange()
{
if (m_isWindowed) {
- notImplemented();
+ uint64_t windowID = 0;
+#if PLATFORM(GTK)
+ windowID = static_cast<uint64_t>(GDK_WINDOW_XID(gtk_plug_get_socket_window(GTK_PLUG(m_platformPluginWidget))));
+#endif
+ IntRect clipRect(m_clipRect);
+ clipRect.move(-m_frameRectInWindowCoordinates.x(), -m_frameRectInWindowCoordinates.y());
+ controller()->windowedPluginGeometryDidChange(m_frameRectInWindowCoordinates, clipRect, windowID);
return;
}
@@ -238,10 +318,8 @@ void NetscapePlugin::platformVisibilityDidChange()
void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect, bool /*isSnapshot*/)
{
- if (m_isWindowed) {
- notImplemented();
+ if (m_isWindowed)
return;
- }
if (!m_isStarted) {
// FIXME: we should paint a missing plugin icon.
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
index e4a624a67..c4d178c6e 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -105,6 +105,7 @@ private:
virtual void contentsScaleFactorChanged(float);
virtual uint64_t pluginComplexTextInputIdentifier() const;
virtual void sendComplexTextInput(const String& textInput);
+ virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
#endif
virtual void privateBrowsingStateChanged(bool);
@@ -113,7 +114,7 @@ private:
virtual WebCore::Scrollbar* horizontalScrollbar();
virtual WebCore::Scrollbar* verticalScrollbar();
- virtual RetainPtr<CGPDFDocumentRef> pdfDocumentForPrinting() const OVERRIDE { return m_pdfDocument; }
+ virtual RetainPtr<PDFDocument> pdfDocumentForPrinting() const OVERRIDE { return m_pdfDocument; }
// ScrollableArea methods.
virtual WebCore::IntRect scrollCornerRect() const;
@@ -150,7 +151,7 @@ private:
String m_suggestedFilename;
RetainPtr<CFMutableDataRef> m_dataBuffer;
- RetainPtr<CGPDFDocumentRef> m_pdfDocument;
+ RetainPtr<PDFDocument> m_pdfDocument;
Vector<WebCore::IntRect> m_pageBoxes;
WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.mm
index d5b8353ee..7dc0b0e64 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,31 +23,33 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "BuiltInPDFView.h"
-
-#include "PluginView.h"
-#include "ShareableBitmap.h"
-#include "WebEvent.h"
-#include "WebEventConversion.h"
-#include <JavaScriptCore/JSContextRef.h>
-#include <JavaScriptCore/JSObjectRef.h>
-#include <JavaScriptCore/JSStringRef.h>
-#include <JavaScriptCore/JSStringRefCF.h>
-#include <WebCore/ArchiveResource.h>
-#include <WebCore/Chrome.h>
-#include <WebCore/DocumentLoader.h>
-#include <WebCore/FocusController.h>
-#include <WebCore/Frame.h>
-#include <WebCore/FrameView.h>
-#include <WebCore/GraphicsContext.h>
-#include <WebCore/HTTPHeaderMap.h>
-#include <WebCore/LocalizedStrings.h>
-#include <WebCore/Page.h>
-#include <WebCore/PluginData.h>
-#include <WebCore/RenderBoxModelObject.h>
-#include <WebCore/ScrollAnimator.h>
-#include <WebCore/ScrollbarTheme.h>
+#import "config.h"
+#import "BuiltInPDFView.h"
+
+#import "PDFKitImports.h"
+#import "PluginView.h"
+#import "ShareableBitmap.h"
+#import "WebEvent.h"
+#import "WebEventConversion.h"
+#import <JavaScriptCore/JSContextRef.h>
+#import <JavaScriptCore/JSObjectRef.h>
+#import <JavaScriptCore/JSStringRef.h>
+#import <JavaScriptCore/JSStringRefCF.h>
+#import <PDFKit/PDFKit.h>
+#import <WebCore/ArchiveResource.h>
+#import <WebCore/Chrome.h>
+#import <WebCore/DocumentLoader.h>
+#import <WebCore/FocusController.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameView.h>
+#import <WebCore/GraphicsContext.h>
+#import <WebCore/HTTPHeaderMap.h>
+#import <WebCore/LocalizedStrings.h>
+#import <WebCore/Page.h>
+#import <WebCore/PluginData.h>
+#import <WebCore/RenderBoxModelObject.h>
+#import <WebCore/ScrollAnimator.h>
+#import <WebCore/ScrollbarTheme.h>
using namespace WebCore;
using namespace std;
@@ -283,8 +285,7 @@ void BuiltInPDFView::pdfDocumentDidLoad()
{
addArchiveResource();
- RetainPtr<CGDataProviderRef> pdfDataProvider(AdoptCF, CGDataProviderCreateWithCFData(m_dataBuffer.get()));
- m_pdfDocument.adoptCF(CGPDFDocumentCreateWithProvider(pdfDataProvider.get()));
+ m_pdfDocument.adoptNS([[pdfDocumentClass() alloc] initWithData:(NSData *)m_dataBuffer.get()]);
calculateSizes();
updateScrollbars();
@@ -292,7 +293,7 @@ void BuiltInPDFView::pdfDocumentDidLoad()
controller()->invalidate(IntRect(0, 0, m_pluginSize.width(), m_pluginSize.height()));
Vector<RetainPtr<CFStringRef> > scripts;
- getAllScriptsInPDFDocument(m_pdfDocument.get(), scripts);
+ getAllScriptsInPDFDocument([m_pdfDocument.get() documentRef], scripts);
size_t scriptCount = scripts.size();
if (!scriptCount)
@@ -312,9 +313,9 @@ void BuiltInPDFView::pdfDocumentDidLoad()
void BuiltInPDFView::calculateSizes()
{
- size_t pageCount = CGPDFDocumentGetNumberOfPages(m_pdfDocument.get());
+ size_t pageCount = CGPDFDocumentGetNumberOfPages([m_pdfDocument.get() documentRef]);
for (size_t i = 0; i < pageCount; ++i) {
- CGPDFPageRef pdfPage = CGPDFDocumentGetPage(m_pdfDocument.get(), i + 1);
+ CGPDFPageRef pdfPage = CGPDFDocumentGetPage([m_pdfDocument.get() documentRef], i + 1);
ASSERT(pdfPage);
CGRect box = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox);
@@ -331,7 +332,7 @@ bool BuiltInPDFView::initialize(const Parameters& parameters)
{
// Load the src URL if needed.
m_sourceURL = parameters.url;
- if (!parameters.loadManually && !parameters.url.isEmpty())
+ if (!parameters.shouldUseManualLoader && !parameters.url.isEmpty())
controller()->loadURL(pdfDocumentRequestID, "GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector<uint8_t>(), false);
return true;
@@ -394,7 +395,7 @@ void BuiltInPDFView::paintContent(GraphicsContext* graphicsContext, const IntRec
if (pageTop > contentRect.maxY())
break;
if (pageTop + pageBox.height() + extraOffsetForCenteringY + gutterHeight >= contentRect.y()) {
- CGPDFPageRef pdfPage = CGPDFDocumentGetPage(m_pdfDocument.get(), i + 1);
+ CGPDFPageRef pdfPage = CGPDFDocumentGetPage([m_pdfDocument.get() documentRef], i + 1);
graphicsContext->save();
graphicsContext->translate(extraOffsetForCenteringX - pageBox.x(), -extraOffsetForCenteringY - pageBox.y() - pageBox.height());
@@ -640,6 +641,10 @@ void BuiltInPDFView::sendComplexTextInput(const String&)
{
}
+void BuiltInPDFView::setLayerHostingMode(LayerHostingMode)
+{
+}
+
#endif
void BuiltInPDFView::privateBrowsingStateChanged(bool)
@@ -706,7 +711,7 @@ bool BuiltInPDFView::isActive() const
return false;
}
-void BuiltInPDFView::invalidateScrollbarRect(Scrollbar* scrollbar, const LayoutRect& rect)
+void BuiltInPDFView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
{
IntRect dirtyRect = rect;
dirtyRect.moveBy(scrollbar->location());
diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.cpp b/Source/WebKit2/WebProcess/Plugins/Plugin.cpp
index 87c9940a5..bc884b962 100644
--- a/Source/WebKit2/WebProcess/Plugins/Plugin.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Plugin.cpp
@@ -38,9 +38,11 @@ void Plugin::Parameters::encode(CoreIPC::ArgumentEncoder* encoder) const
encoder->encode(names);
encoder->encode(values);
encoder->encode(mimeType);
- encoder->encode(loadManually);
- encoder->encode(documentURL);
- encoder->encode(toplevelDocumentURL);
+ encoder->encode(isFullFramePlugin);
+ encoder->encode(shouldUseManualLoader);
+#if PLATFORM(MAC)
+ encoder->encodeEnum(layerHostingMode);
+#endif
}
bool Plugin::Parameters::decode(CoreIPC::ArgumentDecoder* decoder, Parameters& parameters)
@@ -57,13 +59,14 @@ bool Plugin::Parameters::decode(CoreIPC::ArgumentDecoder* decoder, Parameters& p
return false;
if (!decoder->decode(parameters.mimeType))
return false;
- if (!decoder->decode(parameters.loadManually))
+ if (!decoder->decode(parameters.isFullFramePlugin))
return false;
- if (!decoder->decode(parameters.documentURL))
+ if (!decoder->decode(parameters.shouldUseManualLoader))
return false;
- if (!decoder->decode(parameters.toplevelDocumentURL))
+#if PLATFORM(MAC)
+ if (!decoder->decodeEnum(parameters.layerHostingMode))
return false;
-
+#endif
if (parameters.names.size() != parameters.values.size()) {
decoder->markInvalid();
return false;
diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.h b/Source/WebKit2/WebProcess/Plugins/Plugin.h
index 4c656a3a7..4f10da9bc 100644
--- a/Source/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/Source/WebKit2/WebProcess/Plugins/Plugin.h
@@ -33,6 +33,12 @@
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
+#if PLATFORM(MAC)
+#include "LayerHostingContext.h"
+
+OBJC_CLASS PDFDocument;
+#endif
+
struct NPObject;
namespace CoreIPC {
@@ -64,14 +70,11 @@ public:
Vector<String> names;
Vector<String> values;
String mimeType;
- bool loadManually;
-
- // The URL of the document that the plug-in is in.
- String documentURL;
-
- // The URL of the document in the main frame. Will be null if the document the plug-in
- // doesn't have access to the main frame document.
- String toplevelDocumentURL;
+ bool isFullFramePlugin;
+ bool shouldUseManualLoader;
+#if PLATFORM(MAC)
+ LayerHostingMode layerHostingMode;
+#endif
void encode(CoreIPC::ArgumentEncoder*) const;
static bool decode(CoreIPC::ArgumentDecoder*, Parameters&);
@@ -200,6 +203,9 @@ public:
// Send the complex text input to the plug-in.
virtual void sendComplexTextInput(const String& textInput) = 0;
+
+ // Tells the plug-in about changes to the layer hosting mode.
+ virtual void setLayerHostingMode(LayerHostingMode) = 0;
#endif
// Tells the plug-in about scale factor changes.
@@ -219,8 +225,8 @@ public:
virtual WebCore::Scrollbar* horizontalScrollbar() = 0;
virtual WebCore::Scrollbar* verticalScrollbar() = 0;
-#if USE(CG)
- virtual RetainPtr<CGPDFDocumentRef> pdfDocumentForPrinting() const { return 0; }
+#if PLATFORM(MAC)
+ virtual RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return 0; }
#endif
protected:
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginController.h b/Source/WebKit2/WebProcess/Plugins/PluginController.h
index da48eb6e1..25032cca0 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginController.h
+++ b/Source/WebKit2/WebProcess/Plugins/PluginController.h
@@ -85,9 +85,6 @@ public:
// Evaluates the given script string in the context of the given NPObject.
virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups) = 0;
- // Tries to short circuit the NPN_Invoke call with the given parameters. Returns true on success.
- virtual bool tryToShortCircuitInvoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result) = 0;
-
// Set the statusbar text.
virtual void setStatusbarText(const String&) = 0;
@@ -146,6 +143,12 @@ public:
// Decrements a counter that, when it reaches 0, stops preventing the plug-in from being destroyed.
virtual void unprotectPluginFromDestruction() = 0;
+#if PLUGIN_ARCHITECTURE(X11)
+ // Create a plugin container for windowed plugins
+ virtual uint64_t createPluginContainer() = 0;
+ virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID) = 0;
+#endif
+
// Helper class for delaying destruction of a plug-in.
class PluginDestructionProtector {
public:
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp
index b2152713b..8339ad45c 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp
@@ -28,6 +28,8 @@
#if ENABLE(PLUGIN_PROCESS)
+#include <runtime/JSObject.h>
+#include <runtime/ScopeChain.h>
#include "NPRemoteObjectMap.h"
#include "NPRuntimeObjectMap.h"
#include "PluginProcessConnectionManager.h"
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
index 638250e8e..0771bc3d5 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
@@ -523,6 +523,18 @@ void PluginProxy::setStatusbarText(const String& statusbarText)
controller()->setStatusbarText(statusbarText);
}
+#if PLUGIN_ARCHITECTURE(X11)
+void PluginProxy::createPluginContainer(uint64_t& windowID)
+{
+ windowID = controller()->createPluginContainer();
+}
+
+void PluginProxy::windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID)
+{
+ controller()->windowedPluginGeometryDidChange(frameRect, clipRect, windowID);
+}
+#endif
+
void PluginProxy::update(const IntRect& paintedRect)
{
if (paintedRect == pluginBounds())
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
index d2a538777..e4b428669 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
+++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
@@ -100,6 +100,7 @@ private:
virtual void windowVisibilityChanged(bool);
virtual uint64_t pluginComplexTextInputIdentifier() const;
virtual void sendComplexTextInput(const String& textInput);
+ virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
#endif
virtual void contentsScaleFactorChanged(float);
@@ -132,6 +133,11 @@ private:
#if PLATFORM(MAC)
void pluginFocusOrWindowFocusChanged(bool);
void setComplexTextInputState(uint64_t);
+ void setLayerHostingContextID(uint32_t);
+#endif
+#if PLUGIN_ARCHITECTURE(X11)
+ void createPluginContainer(uint64_t& windowID);
+ void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID);
#endif
String m_pluginPath;
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in b/Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in
index ce756169a..a2ef31965 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in
+++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in
@@ -60,8 +60,19 @@ messages -> PluginProxy {
# Called when the plug-in's focus or its containing window focus changes.
PluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus)
- # Change whether complext text input is enabled for this plug-in.
+ # Change whether complex text input is enabled for this plug-in.
SetComplexTextInputState(uint64_t complexTextInputState)
+
+ # Update the layer hosting context ID. Called whenever the layer hosting state changes.
+ SetLayerHostingContextID(uint32_t layerHostingContextID)
+#endif
+
+#if PLUGIN_ARCHITECTURE(X11)
+ # Create the plugin container for windowed plugins
+ CreatePluginContainer() -> (uint64_t windowID)
+
+ # Update geometry of windowed plugin widget
+ WindowedPluginGeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, uint64_t windowID)
#endif
}
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
index 8935dcf78..6799f11b3 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -29,6 +29,7 @@
#include "NPRuntimeUtilities.h"
#include "Plugin.h"
#include "ShareableBitmap.h"
+#include "WebCoreArgumentCoders.h"
#include "WebEvent.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
@@ -289,7 +290,7 @@ PluginView::~PluginView()
m_plugin->destroyPlugin();
m_isBeingDestroyed = false;
#if PLATFORM(MAC)
- setComplexTextInputState(PluginComplexTextInputDisabled);
+ pluginFocusOrWindowFocusChanged(false);
#endif
}
@@ -434,6 +435,19 @@ bool PluginView::sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier,
return true;
}
+void PluginView::setLayerHostingMode(LayerHostingMode layerHostingMode)
+{
+ if (!m_plugin)
+ return;
+
+ if (!m_isInitialized) {
+ m_parameters.layerHostingMode = layerHostingMode;
+ return;
+ }
+
+ m_plugin->setLayerHostingMode(layerHostingMode);
+}
+
#endif
void PluginView::initializePlugin()
@@ -1063,12 +1077,6 @@ bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVari
return m_npRuntimeObjectMap.evaluate(npObject, scriptString, result);
}
-bool PluginView::tryToShortCircuitInvoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result)
-{
- // Never try to short-circuit invoke in the web process.
- return false;
-}
-
void PluginView::setStatusbarText(const String& statusbarText)
{
if (!frame())
@@ -1244,4 +1252,18 @@ void PluginView::didFailLoad(WebFrame* webFrame, bool wasCancelled)
m_plugin->frameDidFail(request->requestID(), wasCancelled);
}
+#if PLUGIN_ARCHITECTURE(X11)
+uint64_t PluginView::createPluginContainer()
+{
+ uint64_t windowID = 0;
+ m_webPage->sendSync(Messages::WebPageProxy::CreatePluginContainer(), Messages::WebPageProxy::CreatePluginContainer::Reply(windowID));
+ return windowID;
+}
+
+void PluginView::windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID)
+{
+ m_webPage->send(Messages::WebPageProxy::WindowedPluginGeometryDidChange(frameRect, clipRect, windowID));
+}
+#endif
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.h b/Source/WebKit2/WebProcess/Plugins/PluginView.h
index cd6363a58..1bf76ae71 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/Source/WebKit2/WebProcess/Plugins/PluginView.h
@@ -65,10 +65,8 @@ public:
void setDeviceScaleFactor(float);
void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
bool sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
-#endif
-
-#if USE(CG)
- RetainPtr<CGPDFDocumentRef> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); }
+ void setLayerHostingMode(LayerHostingMode);
+ RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); }
#endif
// FIXME: Remove this; nobody should have to know about the plug-in view's renderer except the plug-in view itself.
@@ -141,7 +139,6 @@ private:
virtual NPObject* windowScriptNPObject();
virtual NPObject* pluginElementNPObject();
virtual bool evaluate(NPObject*, const String&scriptString, NPVariant* result, bool allowPopups);
- virtual bool tryToShortCircuitInvoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result);
virtual void setStatusbarText(const String&);
virtual bool isAcceleratedCompositingEnabled();
virtual void pluginProcessCrashed();
@@ -163,6 +160,10 @@ private:
virtual bool isPrivateBrowsingEnabled();
virtual void protectPluginFromDestruction();
virtual void unprotectPluginFromDestruction();
+#if PLUGIN_ARCHITECTURE(X11)
+ virtual uint64_t createPluginContainer();
+ virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID);
+#endif
// WebFrame::LoadListener
virtual void didFinishLoad(WebFrame*);
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h
new file mode 100644
index 000000000..200765836
--- /dev/null
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebAlternativeTextClient.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef WebAlternativeTextClient_h
+#define WebAlternativeTextClient_h
+
+#include <WebCore/AlternativeTextClient.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebAlternativeTextClient : public WebCore::AlternativeTextClient {
+public:
+ WebAlternativeTextClient(WebPage *);
+ virtual ~WebAlternativeTextClient();
+ virtual void pageDestroyed() OVERRIDE;
+ virtual void showCorrectionAlternative(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) OVERRIDE;
+ virtual void dismissAlternative(WebCore::ReasonForDismissingAlternativeText) OVERRIDE;
+ virtual String dismissAlternativeSoon(WebCore::ReasonForDismissingAlternativeText) OVERRIDE;
+ virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) OVERRIDE;
+private:
+ WebPage *m_page;
+};
+
+}
+
+#endif // WebAlternativeTextClient_h
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
index 16cb22ae0..5d3afe68a 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
@@ -30,6 +30,7 @@
#include "DrawingArea.h"
#include "InjectedBundleNavigationAction.h"
#include "InjectedBundleUserMessageCoders.h"
+#include "LayerTreeHost.h"
#include "WebCoreArgumentCoders.h"
#include "WebFrame.h"
#include "WebFrameLoaderClient.h"
@@ -438,10 +439,14 @@ void WebChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) con
return;
#if PLATFORM(QT)
- m_page->send(Messages::WebPageProxy::DidChangeContentsSize(size));
-
- if (m_page->useFixedLayout())
+ if (m_page->useFixedLayout()) {
+ // The below method updates the size().
m_page->resizeToContentsIfNeeded();
+ m_page->drawingArea()->layerTreeHost()->sizeDidChange(m_page->size());
+ }
+
+ m_page->send(Messages::WebPageProxy::DidChangeContentsSize(m_page->size()));
+
#endif
FrameView* frameView = frame->view();
@@ -585,16 +590,6 @@ bool WebChromeClient::paintCustomOverhangArea(GraphicsContext* context, const In
return true;
}
-void WebChromeClient::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
-{
- notImplemented();
-}
-
-void WebChromeClient::cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*)
-{
- notImplemented();
-}
-
void WebChromeClient::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser)
{
if (m_page->activeOpenPanelResultListener())
@@ -714,26 +709,16 @@ void WebChromeClient::exitFullScreenForElement(WebCore::Element* element)
}
#endif
-void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments& args) const
+void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments&) const
{
- m_page->send(Messages::WebPageProxy::DidChangeViewportProperties(args));
-
#if USE(TILED_BACKING_STORE)
- // When viewport properties change, recalculate and set the new recommended layout size in case of fixed layout rendering.
- // Viewport properties have no impact on zero sized fixed viewports.
- if (m_page->useFixedLayout() && !m_page->viewportSize().isEmpty()) {
- Settings* settings = m_page->corePage()->settings();
-
- int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_page->viewportSize().width());
+ if (!m_page->useFixedLayout())
+ return;
- IntSize targetLayoutSize = computeViewportAttributes(m_page->corePage()->viewportArguments(),
- minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(),
- settings->deviceDPI(), m_page->viewportSize()).layoutSize;
- m_page->setResizesToContentsUsingLayoutSize(targetLayoutSize);
- }
+ m_page->sendViewportAttributesChanged();
#endif
}
-
+
void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
{
m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
index b68d8d476..969049fac 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
@@ -153,11 +153,6 @@ private:
virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&) OVERRIDE;
- // This is an asynchronous call. The ChromeClient can display UI asking the user for permission
- // to use Geolococation. The ChromeClient must call Geolocation::setShouldClearCache() appropriately.
- virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) OVERRIDE;
- virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) OVERRIDE;
-
virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>) OVERRIDE;
virtual void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader*) OVERRIDE;
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp
index bab9ff1b9..e3af6fc4f 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp
@@ -24,6 +24,9 @@
*/
#include "config.h"
+
+#if ENABLE(CONTEXT_MENUS)
+
#include "WebContextMenuClient.h"
#include "WebContextMenu.h"
@@ -96,3 +99,4 @@ void WebContextMenuClient::showContextMenu()
#endif
} // namespace WebKit
+#endif // ENABLE(CONTEXT_MENUS)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h
index 86b0a4898..96e2ee601 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.h
@@ -26,6 +26,8 @@
#ifndef WebContextMenuClient_h
#define WebContextMenuClient_h
+#if ENABLE(CONTEXT_MENUS)
+
#include <WebCore/ContextMenuClient.h>
namespace WebKit {
@@ -69,4 +71,5 @@ private:
} // namespace WebKit
+#endif // ENABLE(CONTEXT_MENUS)
#endif // WebContextMenuClient_h
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
index 736de2177..f76f2ae67 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
@@ -36,6 +36,8 @@ void WebDragClient::willPerformDragDestinationAction(DragDestinationAction actio
{
if (action == DragDestinationActionLoad)
m_page->willPerformLoadDragDestinationAction();
+ else
+ m_page->mayPerformUploadDragDestinationAction(); // Upload can happen from a drop event handler, so we should prepare early.
}
void WebDragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
@@ -58,12 +60,6 @@ void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Cl
}
#endif
-#if !PLATFORM(MAC)
-void WebDragClient::dragEnded()
-{
-}
-#endif
-
void WebDragClient::dragControllerDestroyed()
{
delete this;
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
index a9411ac40..bcee69362 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
@@ -28,11 +28,6 @@
#include <WebCore/DragClient.h>
-#if PLATFORM(MAC)
-OBJC_CLASS WKPasteboardFilePromiseOwner;
-OBJC_CLASS WKPasteboardOwner;
-#endif
-
namespace WebKit {
class WebPage;
@@ -56,16 +51,9 @@ private:
virtual void declareAndWriteDragImage(const String& pasteboardName, DOMElement*, NSURL*, NSString*, WebCore::Frame*) OVERRIDE;
#endif
- virtual void dragEnded() OVERRIDE;
-
virtual void dragControllerDestroyed() OVERRIDE;
WebPage* m_page;
-
-#if PLATFORM(MAC)
- RetainPtr<WKPasteboardFilePromiseOwner> m_filePromiseOwner;
- RetainPtr<WKPasteboardOwner> m_pasteboardOwner;
-#endif
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
index 010cd4b4f..774cc1c13 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
@@ -142,11 +142,8 @@ private:
virtual void willSetInputMethodState() OVERRIDE;
virtual void setInputMethodState(bool enabled) OVERRIDE;
virtual void requestCheckingOfString(WebCore::SpellChecker*, const WebCore::TextCheckingRequest&) OVERRIDE;
-#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
- virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) OVERRIDE;
- virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) OVERRIDE;
- virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel) OVERRIDE;
- virtual void recordAutocorrectionResponse(AutocorrectionResponseType, const String& replacedString, const String& replacementString) OVERRIDE;
+#if PLATFORM(GTK)
+ virtual bool shouldShowUnicodeMenu() OVERRIDE;
#endif
WebPage* m_page;
};
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
index 67f42b2a3..5366cc9f4 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -28,6 +28,9 @@
#include "AuthenticationManager.h"
#include "DataReference.h"
+#include "InjectedBundle.h"
+#include "InjectedBundleBackForwardListItem.h"
+#include "InjectedBundleDOMWindowExtension.h"
#include "InjectedBundleNavigationAction.h"
#include "InjectedBundleUserMessageCoders.h"
#include "PlatformCertificateInfo.h"
@@ -40,6 +43,7 @@
#include "WebEvent.h"
#include "WebFrame.h"
#include "WebFrameNetworkingContext.h"
+#include "WebFullScreenManager.h"
#include "WebNavigationDataStore.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
@@ -77,6 +81,7 @@ WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame)
: m_frame(frame)
, m_hasSentResponseToPluginView(false)
, m_frameHasCustomRepresentation(false)
+ , m_frameCameFromPageCache(false)
{
}
@@ -386,6 +391,11 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
if (!webPage)
return;
+#if ENABLE(FULLSCREEN_API)
+ if (m_frame->coreFrame()->document()->webkitIsFullScreen())
+ webPage->fullScreenManager()->close();
+#endif
+
webPage->findController().hideFindUI();
webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame);
@@ -539,6 +549,11 @@ void WebFrameLoaderClient::dispatchDidFirstLayout()
if (m_frame == m_frame->page()->mainWebFrame() && !webPage->corePage()->settings()->suppressesIncrementalRendering())
webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
+
+#if USE(TILED_BACKING_STORE)
+ // Make sure viewport properties are dispatched on the main frame by the time the first layout happens.
+ ASSERT(!webPage->useFixedLayout() || m_frame != m_frame->page()->mainWebFrame() || m_frame->coreFrame()->document()->didDispatchViewportPropertiesChanged());
+#endif
}
void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout()
@@ -730,6 +745,19 @@ void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&
webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
}
+void WebFrameLoaderClient::dispatchWillSendSubmitEvent(PassRefPtr<FormState> prpFormState)
+{
+ WebPage* webPage = m_frame->page();
+ if (!webPage)
+ return;
+
+ RefPtr<FormState> formState = prpFormState;
+ HTMLFormElement* form = formState->form();
+ WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
+
+ webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, form, m_frame, sourceFrame, formState->textFieldValues());
+}
+
void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> prpFormState)
{
WebPage* webPage = m_frame->page();
@@ -740,7 +768,7 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function,
RefPtr<FormState> formState = prpFormState;
HTMLFormElement* form = formState->form();
- WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceFrame()->loader()->client())->webFrame();
+ WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
const Vector<std::pair<String, String> >& values = formState->textFieldValues();
RefPtr<APIObject> userData;
@@ -753,11 +781,6 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function,
webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
}
-void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
-{
- notImplemented();
-}
-
void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
{
notImplemented();
@@ -862,8 +885,6 @@ void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* dat
void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
{
if (!m_pluginView) {
- committedLoad(loader, 0, 0);
-
if (m_frameHasCustomRepresentation) {
WebPage* webPage = m_frame->page();
if (!webPage)
@@ -874,13 +895,14 @@ void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomRepresentation(loader->response().suggestedFilename(), dataReference));
}
-
- return;
}
- m_pluginView->manualLoadDidFinishLoading();
- m_pluginView = 0;
- m_hasSentResponseToPluginView = false;
+ // Plugin view could have been created inside committedLoad().
+ if (m_pluginView) {
+ m_pluginView->manualLoadDidFinishLoading();
+ m_pluginView = 0;
+ m_hasSentResponseToPluginView = false;
+ }
}
void WebFrameLoaderClient::updateGlobalHistory()
@@ -934,13 +956,20 @@ bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const
ASSERT_NOT_REACHED();
return false;
}
+
+ RefPtr<InjectedBundleBackForwardListItem> bundleItem = InjectedBundleBackForwardListItem::create(item);
+ RefPtr<APIObject> userData;
+
+ // Ask the bundle client first
+ bool shouldGoToBackForwardListItem = webPage->injectedBundleLoaderClient().shouldGoToBackForwardListItem(webPage, bundleItem.get(), userData);
+ if (!shouldGoToBackForwardListItem)
+ return false;
if (webPage->willGoToBackForwardItemCallbackEnabled()) {
- webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID));
+ webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, InjectedBundleUserMessageEncoder(userData.get())));
return true;
}
- bool shouldGoToBackForwardListItem;
if (!webPage->sendSync(Messages::WebPageProxy::ShouldGoToBackForwardListItem(itemID), Messages::WebPageProxy::ShouldGoToBackForwardListItem::Reply(shouldGoToBackForwardListItem)))
return false;
@@ -1161,6 +1190,7 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
+ m_frameCameFromPageCache = true;
}
void WebFrameLoaderClient::transitionToCommittedForNewPage()
@@ -1171,10 +1201,9 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
bool isMainFrame = webPage->mainWebFrame() == m_frame;
bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout();
-#if !USE(TILED_BACKING_STORE)
const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
-#endif
+ m_frameCameFromPageCache = false;
m_frame->coreFrame()->createView(webPage->size(), backgroundColor, /* transparent */ false, IntSize(), shouldUseFixedLayout);
m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground());
@@ -1244,22 +1273,15 @@ PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const Strin
m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe);
// The frame's onload handler may have removed it from the document.
+ if (!subframe->coreFrame())
+ return 0;
+ ASSERT(subframe->coreFrame() == coreSubframe);
if (!coreSubframe->tree()->parent())
return 0;
return coreSubframe;
}
-void WebFrameLoaderClient::didTransferChildFrameToNewDocument(Page*)
-{
- notImplemented();
-}
-
-void WebFrameLoaderClient::transferLoadingResourceFromPage(ResourceLoader*, const ResourceRequest&, Page*)
-{
- notImplemented();
-}
-
PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
{
ASSERT(paramNames.size() == paramValues.size());
@@ -1272,16 +1294,11 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn
parameters.names = paramNames;
parameters.values = paramValues;
parameters.mimeType = mimeType;
- parameters.loadManually = loadManually;
- parameters.documentURL = m_frame->coreFrame()->document()->url().string();
-
- Frame* mainFrame = webPage->mainWebFrame()->coreFrame();
- if (m_frame->coreFrame() == mainFrame)
- parameters.toplevelDocumentURL = parameters.documentURL;
- else if (m_frame->coreFrame()->document()->securityOrigin()->canAccess(mainFrame->document()->securityOrigin())) {
- // We only want to set the toplevel document URL if the plug-in has access to it.
- parameters.toplevelDocumentURL = mainFrame->document()->url().string();
- }
+ parameters.isFullFramePlugin = loadManually;
+ parameters.shouldUseManualLoader = parameters.isFullFramePlugin && !m_frameCameFromPageCache;
+#if PLATFORM(MAC)
+ parameters.layerHostingMode = webPage->layerHostingMode();
+#endif
#if PLUGIN_ARCHITECTURE(X11)
// FIXME: This should really be X11-specific plug-in quirks.
@@ -1405,6 +1422,43 @@ void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*
#endif
}
+
+void WebFrameLoaderClient::dispatchGlobalObjectAvailable(DOMWrapperWorld* world)
+{
+ WebPage* webPage = m_frame->page();
+ if (!webPage)
+ return;
+
+ webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(webPage, m_frame, world);
+}
+
+void WebFrameLoaderClient::dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension* extension)
+{
+ WebPage* webPage = m_frame->page();
+ if (!webPage)
+ return;
+
+ webPage->injectedBundleLoaderClient().willDisconnectDOMWindowExtensionFromGlobalObject(webPage, extension);
+}
+
+void WebFrameLoaderClient::dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension* extension)
+{
+ WebPage* webPage = m_frame->page();
+ if (!webPage)
+ return;
+
+ webPage->injectedBundleLoaderClient().didReconnectDOMWindowExtensionToGlobalObject(webPage, extension);
+}
+
+void WebFrameLoaderClient::dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension* extension)
+{
+ WebPage* webPage = m_frame->page();
+ if (!webPage)
+ return;
+
+ webPage->injectedBundleLoaderClient().willDestroyGlobalObjectForDOMWindowExtension(webPage, extension);
+}
+
void WebFrameLoaderClient::documentElementAvailable()
{
notImplemented();
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
index a93ecee92..96664b63d 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
@@ -106,10 +106,9 @@ private:
virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) OVERRIDE;
- virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) OVERRIDE { }
+ virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) OVERRIDE;
virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>) OVERRIDE;
- virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*) OVERRIDE;
virtual void revertToProvisionalState(WebCore::DocumentLoader*) OVERRIDE;
virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) OVERRIDE;
@@ -183,8 +182,6 @@ private:
virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) OVERRIDE;
- virtual void didTransferChildFrameToNewDocument(WebCore::Page*) OVERRIDE;
- virtual void transferLoadingResourceFromPage(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, WebCore::Page*) OVERRIDE;
virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) OVERRIDE;
virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) OVERRIDE;
@@ -195,6 +192,11 @@ private:
virtual String overrideMediaType() const OVERRIDE;
virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*) OVERRIDE;
+
+ virtual void dispatchGlobalObjectAvailable(WebCore::DOMWrapperWorld*) OVERRIDE;
+ virtual void dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension*) OVERRIDE;
+ virtual void dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension*) OVERRIDE;
+ virtual void dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension*) OVERRIDE;
virtual void documentElementAvailable() OVERRIDE;
virtual void didPerformFirstNavigation() const OVERRIDE; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
@@ -224,6 +226,7 @@ private:
RefPtr<PluginView> m_pluginView;
bool m_hasSentResponseToPluginView;
bool m_frameHasCustomRepresentation;
+ bool m_frameCameFromPageCache;
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp
index 1f920a1fb..993f99e98 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "WebGeolocationClient.h"
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
+#if ENABLE(GEOLOCATION)
#include "WebGeolocationManager.h"
#include "WebPage.h"
@@ -80,4 +80,4 @@ void WebGeolocationClient::cancelPermissionRequest(Geolocation* geolocation)
} // namespace WebKit
-#endif // ENABLE(CLIENT_BASED_GEOLOCATION)
+#endif // ENABLE(GEOLOCATION)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h
index 21fc4383f..9e5713937 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGeolocationClient.h
@@ -26,8 +26,6 @@
#ifndef WebGeolocationClient_h
#define WebGeolocationClient_h
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
-
#include <WebCore/GeolocationClient.h>
namespace WebKit {
@@ -61,6 +59,4 @@ private:
} // namespace WebKit
-#endif // ENABLE(CLIENT_BASED_GEOLOCATION)
-
#endif // WebGeolocationClient_h
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
index 8808566aa..80e8b61f3 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
@@ -22,7 +22,6 @@
#if USE(UI_SIDE_COMPOSITING)
#include "WebGraphicsLayer.h"
-#include "Animation.h"
#include "BackingStore.h"
#include "FloatQuad.h"
#include "Frame.h"
@@ -33,9 +32,9 @@
#include "Page.h"
#include "TiledBackingStoreRemoteTile.h"
#include "WebPage.h"
-#include "text/CString.h"
-#include <HashMap.h>
#include <wtf/CurrentTime.h>
+#include <wtf/HashMap.h>
+#include <wtf/text/CString.h>
using namespace WebKit;
@@ -61,37 +60,60 @@ static WebLayerID toWebLayerID(GraphicsLayer* layer)
return layer ? toWebGraphicsLayer(layer)->id() : 0;
}
-void WebGraphicsLayer::notifyChange()
+void WebGraphicsLayer::didChangeLayerState()
{
- m_modified = true;
+ m_shouldSyncLayerState = true;
if (client())
client()->notifySyncRequired(this);
}
-void WebGraphicsLayer::notifyChangeRecursively()
+void WebGraphicsLayer::didChangeChildren()
{
- notifyChange();
+ m_shouldSyncChildren = true;
+ if (client())
+ client()->notifySyncRequired(this);
+}
+
+#if ENABLE(CSS_FILTERS)
+void WebGraphicsLayer::didChangeFilters()
+{
+ m_shouldSyncFilters = true;
+ if (client())
+ client()->notifySyncRequired(this);
+}
+#endif
+
+void WebGraphicsLayer::setShouldUpdateVisibleRect()
+{
+ if (!transform().isAffine())
+ return;
+
+ m_shouldUpdateVisibleRect = true;
for (size_t i = 0; i < children().size(); ++i)
- toWebGraphicsLayer(children()[i])->notifyChangeRecursively();
+ toWebGraphicsLayer(children()[i])->setShouldUpdateVisibleRect();
if (replicaLayer())
- toWebGraphicsLayer(replicaLayer())->notifyChange();
+ toWebGraphicsLayer(replicaLayer())->setShouldUpdateVisibleRect();
+}
+
+void WebGraphicsLayer::didChangeGeometry()
+{
+ didChangeLayerState();
+ setShouldUpdateVisibleRect();
}
WebGraphicsLayer::WebGraphicsLayer(GraphicsLayerClient* client)
: GraphicsLayer(client)
, m_maskTarget(0)
- , m_needsDisplay(false)
- , m_modified(true)
- , m_contentNeedsDisplay(false)
- , m_hasPendingAnimations(false)
, m_inUpdateMode(false)
-#if USE(TILED_BACKING_STORE)
+ , m_shouldUpdateVisibleRect(true)
+ , m_shouldSyncLayerState(true)
+ , m_shouldSyncChildren(true)
+ , m_fixedToViewport(false)
, m_webGraphicsLayerClient(0)
- , m_contentsScale(1.f)
-#endif
+ , m_contentsScale(1)
{
static WebLayerID nextLayerID = 1;
- m_layerInfo.id = nextLayerID++;
+ m_id = nextLayerID++;
layerByIDMap().add(id(), this);
}
@@ -103,6 +125,12 @@ WebGraphicsLayer::~WebGraphicsLayer()
purgeBackingStores();
m_webGraphicsLayerClient->detachLayer(this);
}
+ willBeDestroyed();
+}
+
+void WebGraphicsLayer::willBeDestroyed()
+{
+ GraphicsLayer::willBeDestroyed();
}
bool WebGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
@@ -113,9 +141,9 @@ bool WebGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
for (int i = 0; i < children.size(); ++i) {
WebGraphicsLayer* child = toWebGraphicsLayer(children[i]);
child->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
- child->notifyChange();
+ child->didChangeLayerState();
}
- notifyChange();
+ didChangeChildren();
return true;
}
@@ -123,32 +151,32 @@ void WebGraphicsLayer::addChild(GraphicsLayer* layer)
{
GraphicsLayer::addChild(layer);
toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
- toWebGraphicsLayer(layer)->notifyChange();
- notifyChange();
+ toWebGraphicsLayer(layer)->didChangeLayerState();
+ didChangeChildren();
}
void WebGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index)
{
GraphicsLayer::addChildAtIndex(layer, index);
toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
- toWebGraphicsLayer(layer)->notifyChange();
- notifyChange();
+ toWebGraphicsLayer(layer)->didChangeLayerState();
+ didChangeChildren();
}
void WebGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
{
GraphicsLayer::addChildAbove(layer, sibling);
toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
- toWebGraphicsLayer(layer)->notifyChange();
- notifyChange();
+ toWebGraphicsLayer(layer)->didChangeLayerState();
+ didChangeChildren();
}
void WebGraphicsLayer::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
{
GraphicsLayer::addChildBelow(layer, sibling);
toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
- toWebGraphicsLayer(layer)->notifyChange();
- notifyChange();
+ toWebGraphicsLayer(layer)->didChangeLayerState();
+ didChangeChildren();
}
bool WebGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
@@ -156,20 +184,20 @@ bool WebGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newC
bool ok = GraphicsLayer::replaceChild(oldChild, newChild);
if (!ok)
return false;
- notifyChange();
- toWebGraphicsLayer(oldChild)->notifyChange();
+ didChangeChildren();
+ toWebGraphicsLayer(oldChild)->didChangeLayerState();
toWebGraphicsLayer(newChild)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
- toWebGraphicsLayer(newChild)->notifyChange();
+ toWebGraphicsLayer(newChild)->didChangeLayerState();
return true;
}
void WebGraphicsLayer::removeFromParent()
{
if (WebGraphicsLayer* parentLayer = toWebGraphicsLayer(parent()))
- parentLayer->notifyChange();
+ parentLayer->didChangeChildren();
GraphicsLayer::removeFromParent();
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setPosition(const FloatPoint& p)
@@ -178,7 +206,7 @@ void WebGraphicsLayer::setPosition(const FloatPoint& p)
return;
GraphicsLayer::setPosition(p);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setAnchorPoint(const FloatPoint3D& p)
@@ -187,7 +215,7 @@ void WebGraphicsLayer::setAnchorPoint(const FloatPoint3D& p)
return;
GraphicsLayer::setAnchorPoint(p);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setSize(const FloatSize& size)
@@ -199,7 +227,7 @@ void WebGraphicsLayer::setSize(const FloatSize& size)
setNeedsDisplay();
if (maskLayer())
maskLayer()->setSize(size);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setTransform(const TransformationMatrix& t)
@@ -208,7 +236,7 @@ void WebGraphicsLayer::setTransform(const TransformationMatrix& t)
return;
GraphicsLayer::setTransform(t);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setChildrenTransform(const TransformationMatrix& t)
@@ -217,7 +245,7 @@ void WebGraphicsLayer::setChildrenTransform(const TransformationMatrix& t)
return;
GraphicsLayer::setChildrenTransform(t);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setPreserves3D(bool b)
@@ -226,7 +254,7 @@ void WebGraphicsLayer::setPreserves3D(bool b)
return;
GraphicsLayer::setPreserves3D(b);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setMasksToBounds(bool b)
@@ -234,7 +262,7 @@ void WebGraphicsLayer::setMasksToBounds(bool b)
if (masksToBounds() == b)
return;
GraphicsLayer::setMasksToBounds(b);
- notifyChangeRecursively();
+ didChangeGeometry();
}
void WebGraphicsLayer::setDrawsContent(bool b)
@@ -243,7 +271,7 @@ void WebGraphicsLayer::setDrawsContent(bool b)
return;
GraphicsLayer::setDrawsContent(b);
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setContentsOpaque(bool b)
@@ -253,7 +281,7 @@ void WebGraphicsLayer::setContentsOpaque(bool b)
if (m_mainBackingStore)
m_mainBackingStore->setSupportsAlpha(!b);
GraphicsLayer::setContentsOpaque(b);
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setBackfaceVisibility(bool b)
@@ -262,7 +290,7 @@ void WebGraphicsLayer::setBackfaceVisibility(bool b)
return;
GraphicsLayer::setBackfaceVisibility(b);
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setOpacity(float opacity)
@@ -271,7 +299,7 @@ void WebGraphicsLayer::setOpacity(float opacity)
return;
GraphicsLayer::setOpacity(opacity);
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setContentsRect(const IntRect& r)
@@ -280,54 +308,7 @@ void WebGraphicsLayer::setContentsRect(const IntRect& r)
return;
GraphicsLayer::setContentsRect(r);
- notifyChange();
-}
-
-void WebGraphicsLayer::notifyAnimationStarted(double time)
-{
- if (client())
- client()->notifyAnimationStarted(this, time);
-}
-
-bool WebGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset)
-{
- if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity))
- return false;
-
- WebLayerAnimation webAnimation(valueList);
- webAnimation.name = keyframesName;
- webAnimation.operation = WebLayerAnimation::AddAnimation;
- webAnimation.boxSize = boxSize;
- webAnimation.animation = Animation::create(anim);
- webAnimation.startTime = timeOffset;
- m_layerInfo.animations.append(webAnimation);
- if (valueList.property() == AnimatedPropertyWebkitTransform)
- m_transformAnimations.add(keyframesName);
-
- m_hasPendingAnimations = true;
- notifyChangeRecursively();
-
- return true;
-}
-
-void WebGraphicsLayer::pauseAnimation(const String& animationName, double timeOffset)
-{
- WebLayerAnimation webAnimation;
- webAnimation.name = animationName;
- webAnimation.operation = WebLayerAnimation::PauseAnimation;
- webAnimation.startTime = WTF::currentTime() - timeOffset;
- m_layerInfo.animations.append(webAnimation);
- notifyChange();
-}
-
-void WebGraphicsLayer::removeAnimation(const String& animationName)
-{
- WebLayerAnimation webAnimation;
- webAnimation.name = animationName;
- webAnimation.operation = WebLayerAnimation::RemoveAnimation;
- m_layerInfo.animations.append(webAnimation);
- m_transformAnimations.remove(animationName);
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setContentsNeedsDisplay()
@@ -337,6 +318,17 @@ void WebGraphicsLayer::setContentsNeedsDisplay()
setContentsToImage(image.get());
}
+#if ENABLE(CSS_FILTERS)
+bool WebGraphicsLayer::setFilters(const FilterOperations& newFilters)
+{
+ if (filters() == newFilters)
+ return true;
+ didChangeFilters();
+ return GraphicsLayer::setFilters(newFilters);
+}
+#endif
+
+
void WebGraphicsLayer::setContentsToImage(Image* image)
{
if (image == m_image)
@@ -346,18 +338,17 @@ void WebGraphicsLayer::setContentsToImage(Image* image)
// We adopt first, in case this is the same frame - that way we avoid destroying and recreating the image.
newID = m_webGraphicsLayerClient->adoptImageBackingStore(image);
m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
- notifyChange();
+ didChangeLayerState();
if (m_layerInfo.imageBackingStoreID && newID == m_layerInfo.imageBackingStoreID)
return;
} else {
// If m_webGraphicsLayerClient is not set yet there should be no backing store ID.
ASSERT(!m_layerInfo.imageBackingStoreID);
- notifyChange();
+ didChangeLayerState();
}
m_layerInfo.imageBackingStoreID = newID;
m_image = image;
- m_layerInfo.imageIsUpdated = true;
GraphicsLayer::setContentsToImage(image);
}
@@ -375,8 +366,8 @@ void WebGraphicsLayer::setMaskLayer(GraphicsLayer* layer)
WebGraphicsLayer* webGraphicsLayer = toWebGraphicsLayer(layer);
webGraphicsLayer->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
webGraphicsLayer->setMaskTarget(this);
- webGraphicsLayer->notifyChange();
- notifyChange();
+ webGraphicsLayer->didChangeLayerState();
+ didChangeLayerState();
}
@@ -389,7 +380,7 @@ void WebGraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
toWebGraphicsLayer(layer)->setWebGraphicsLayerClient(m_webGraphicsLayerClient);
GraphicsLayer::setReplicatedByLayer(layer);
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setNeedsDisplay()
@@ -401,12 +392,12 @@ void WebGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
{
if (m_mainBackingStore)
m_mainBackingStore->invalidate(IntRect(rect));
- notifyChange();
+ didChangeLayerState();
}
WebLayerID WebGraphicsLayer::id() const
{
- return m_layerInfo.id;
+ return m_id;
}
void WebGraphicsLayer::syncCompositingState(const FloatRect& rect)
@@ -417,6 +408,8 @@ void WebGraphicsLayer::syncCompositingState(const FloatRect& rect)
if (WebGraphicsLayer* replica = toWebGraphicsLayer(replicaLayer()))
replica->syncCompositingStateForThisLayerOnly();
+ m_webGraphicsLayerClient->syncFixedLayers();
+
syncCompositingStateForThisLayerOnly();
for (size_t i = 0; i < children().size(); ++i)
@@ -428,15 +421,35 @@ WebGraphicsLayer* toWebGraphicsLayer(GraphicsLayer* layer)
return static_cast<WebGraphicsLayer*>(layer);
}
-void WebGraphicsLayer::syncCompositingStateForThisLayerOnly()
+void WebGraphicsLayer::syncChildren()
{
- updateContentBuffers();
+ if (!m_shouldSyncChildren)
+ return;
+ m_shouldSyncChildren = false;
+ Vector<WebLayerID> childIDs;
+ for (size_t i = 0; i < children().size(); ++i)
+ childIDs.append(toWebLayerID(children()[i]));
+
+ m_webGraphicsLayerClient->syncLayerChildren(m_id, childIDs);
+}
- if (!m_modified)
+#if ENABLE(CSS_FILTERS)
+void WebGraphicsLayer::syncFilters()
+{
+ if (!m_shouldSyncFilters)
return;
+ m_shouldSyncFilters = false;
+ m_webGraphicsLayerClient->syncLayerFilters(m_id, filters());
+}
+#endif
+
+void WebGraphicsLayer::syncLayerState()
+ {
+ if (!m_shouldSyncLayerState)
+ return;
+ m_shouldSyncLayerState = false;
+ m_layerInfo.fixedToViewport = fixedToViewport();
- computeTransformedVisibleRect();
- m_layerInfo.name = name();
m_layerInfo.anchorPoint = anchorPoint();
m_layerInfo.backfaceVisible = backfaceVisibility();
m_layerInfo.childrenTransform = childrenTransform();
@@ -452,22 +465,29 @@ void WebGraphicsLayer::syncCompositingStateForThisLayerOnly()
m_layerInfo.replica = toWebLayerID(replicaLayer());
m_layerInfo.size = size();
m_layerInfo.transform = transform();
- m_contentNeedsDisplay = false;
- m_layerInfo.children.clear();
-
- for (size_t i = 0; i < children().size(); ++i)
- m_layerInfo.children.append(toWebLayerID(children()[i]));
+ m_webGraphicsLayerClient->syncLayerState(m_id, m_layerInfo);
+}
- m_webGraphicsLayerClient->didSyncCompositingStateForLayer(m_layerInfo);
- m_modified = false;
- m_layerInfo.imageIsUpdated = false;
- if (m_hasPendingAnimations)
- notifyAnimationStarted(WTF::currentTime());
- m_layerInfo.animations.clear();
- m_hasPendingAnimations = false;
+void WebGraphicsLayer::ensureImageBackingStore()
+{
+ if (!m_image)
+ return;
+ if (!m_layerInfo.imageBackingStoreID)
+ m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
+}
+void WebGraphicsLayer::syncCompositingStateForThisLayerOnly()
+{
+ // The remote image might have been released by purgeBackingStores.
+ ensureImageBackingStore();
+ computeTransformedVisibleRect();
+ syncChildren();
+ syncLayerState();
+#if ENABLE(CSS_FILTERS)
+ syncFilters();
+#endif
+ updateContentBuffers();
}
-#if USE(TILED_BACKING_STORE)
void WebGraphicsLayer::tiledBackingStorePaintBegin()
{
}
@@ -475,7 +495,7 @@ void WebGraphicsLayer::tiledBackingStorePaintBegin()
void WebGraphicsLayer::setRootLayer(bool isRoot)
{
m_layerInfo.isRootLayer = isRoot;
- notifyChange();
+ didChangeLayerState();
}
void WebGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
@@ -487,8 +507,20 @@ void WebGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& t
void WebGraphicsLayer::setContentsScale(float scale)
{
m_contentsScale = scale;
+ adjustContentsScale();
+}
+
+float WebGraphicsLayer::effectiveContentsScale()
+{
+ return shouldUseTiledBackingStore() ? m_contentsScale : 1;
+}
- if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == scale)
+void WebGraphicsLayer::adjustContentsScale()
+{
+ if (!drawsContent())
+ return;
+
+ if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == effectiveContentsScale())
return;
// Between creating the new backing store and painting the content,
@@ -507,14 +539,13 @@ void WebGraphicsLayer::createBackingStore()
{
m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
m_mainBackingStore->setSupportsAlpha(!contentsOpaque());
- m_mainBackingStore->setContentsScale(m_contentsScale);
+ m_mainBackingStore->setContentsScale(effectiveContentsScale());
}
void WebGraphicsLayer::tiledBackingStorePaint(GraphicsContext* context, const IntRect& rect)
{
if (rect.isEmpty())
return;
- m_modified = true;
paintGraphicsLayerContents(*context, rect);
}
@@ -534,11 +565,14 @@ IntRect WebGraphicsLayer::tiledBackingStoreContentsRect()
return IntRect(0, 0, size().width(), size().height());
}
+bool WebGraphicsLayer::shouldUseTiledBackingStore()
+{
+ return !selfOrAncestorHaveNonAffineTransforms();
+}
+
IntRect WebGraphicsLayer::tiledBackingStoreVisibleRect()
{
- // 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())
+ if (!shouldUseTiledBackingStore())
return tiledBackingStoreContentsRect();
// Non-invertible layers are not visible.
@@ -548,42 +582,36 @@ IntRect WebGraphicsLayer::tiledBackingStoreVisibleRect()
// 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_webGraphicsLayerClient->visibleContentsRect())));
+ return enclosingIntRect(m_layerTransform.combined().inverse().clampedBoundsOfProjectedQuad(FloatQuad(FloatRect(m_webGraphicsLayerClient->visibleContentsRect()))));
}
Color WebGraphicsLayer::tiledBackingStoreBackgroundColor() const
{
return contentsOpaque() ? Color::white : Color::transparent;
+}
+PassOwnPtr<WebCore::GraphicsContext> WebGraphicsLayer::beginContentUpdate(const WebCore::IntSize& size, ShareableSurface::Handle& handle, WebCore::IntPoint& offset)
+{
+ return m_webGraphicsLayerClient->beginContentUpdate(size, contentsOpaque() ? 0 : ShareableBitmap::SupportsAlpha, handle, offset);
}
-void WebGraphicsLayer::createTile(int tileID, const UpdateInfo& updateInfo)
+
+void WebGraphicsLayer::createTile(int tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& targetRect)
{
- m_modified = true;
- m_webGraphicsLayerClient->createTile(id(), tileID, updateInfo);
+ m_webGraphicsLayerClient->createTile(id(), tileID, updateInfo, targetRect);
}
-void WebGraphicsLayer::updateTile(int tileID, const UpdateInfo& updateInfo)
+void WebGraphicsLayer::updateTile(int tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& targetRect)
{
- m_modified = true;
- m_webGraphicsLayerClient->updateTile(id(), tileID, updateInfo);
+ m_webGraphicsLayerClient->updateTile(id(), tileID, updateInfo, targetRect);
}
void WebGraphicsLayer::removeTile(int tileID)
{
- m_modified = true;
m_webGraphicsLayerClient->removeTile(id(), tileID);
}
void WebGraphicsLayer::updateContentBuffers()
{
- // The remote image might have been released by purgeBackingStores.
- if (m_image) {
- if (!m_layerInfo.imageBackingStoreID) {
- m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
- m_layerInfo.imageIsUpdated = true;
- }
- }
-
if (!drawsContent()) {
m_mainBackingStore.clear();
m_previousBackingStore.clear();
@@ -614,6 +642,9 @@ void WebGraphicsLayer::purgeBackingStores()
m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
m_layerInfo.imageBackingStoreID = 0;
}
+
+ didChangeLayerState();
+ didChangeChildren();
}
void WebGraphicsLayer::setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient* client)
@@ -648,7 +679,9 @@ void WebGraphicsLayer::adjustVisibleRect()
void WebGraphicsLayer::computeTransformedVisibleRect()
{
- // FIXME: Consider transform animations in the visible rect calculation.
+ if (!m_shouldUpdateVisibleRect)
+ return;
+ m_shouldUpdateVisibleRect = false;
m_layerTransform.setLocalTransform(transform());
m_layerTransform.setPosition(position());
m_layerTransform.setAnchorPoint(anchorPoint());
@@ -659,8 +692,8 @@ void WebGraphicsLayer::computeTransformedVisibleRect()
// The combined transform will be used in tiledBackingStoreVisibleRect.
adjustVisibleRect();
+ adjustContentsScale();
}
-#endif
static PassOwnPtr<GraphicsLayer> createWebGraphicsLayer(GraphicsLayerClient* client)
{
@@ -672,14 +705,11 @@ void WebGraphicsLayer::initFactory()
GraphicsLayer::setGraphicsLayerFactory(createWebGraphicsLayer);
}
-bool WebGraphicsLayer::selfOrAncestorHasActiveTransformAnimations() const
+bool WebGraphicsLayer::selfOrAncestorHaveNonAffineTransforms()
{
- if (!m_transformAnimations.isEmpty())
+ if (!m_layerTransform.combined().isAffine())
return true;
- if (parent())
- return toWebGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimations();
-
return false;
}
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
index 0ca5aa54a..c22a88243 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
@@ -47,17 +47,23 @@ namespace WebKit {
class WebGraphicsLayerClient {
public:
// TiledBackingStoreRemoteTileClient
- virtual void createTile(WebLayerID, int tileID, const UpdateInfo&) = 0;
- virtual void updateTile(WebLayerID, int tileID, const UpdateInfo&) = 0;
+ virtual void createTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
+ virtual void updateTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
virtual void removeTile(WebLayerID, int tileID) = 0;
virtual WebCore::IntRect visibleContentsRect() const = 0;
virtual bool layerTreeTileUpdatesAllowed() const = 0;
virtual int64_t adoptImageBackingStore(WebCore::Image*) = 0;
virtual void releaseImageBackingStore(int64_t) = 0;
- virtual void didSyncCompositingStateForLayer(const WebLayerInfo&) = 0;
+ virtual void syncLayerState(WebLayerID, const WebLayerInfo&) = 0;
+ virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&) = 0;
+#if ENABLE(CSS_FILTERS)
+ virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&) = 0;
+#endif
virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0;
virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0;
+ virtual void syncFixedLayers() = 0;
+ virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&) = 0;
};
}
@@ -91,9 +97,6 @@ public:
void setBackfaceVisibility(bool);
void setOpacity(float);
void setContentsRect(const IntRect&);
- bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double);
- void pauseAnimation(const String&, double);
- void removeAnimation(const String&);
void setContentsToImage(Image*);
void setMaskLayer(GraphicsLayer*);
void setReplicatedByLayer(GraphicsLayer*);
@@ -104,21 +107,25 @@ public:
void setVisibleContentRectTrajectoryVector(const FloatPoint&);
virtual void syncCompositingState(const FloatRect&);
virtual void syncCompositingStateForThisLayerOnly();
+#if ENABLE(CSS_FILTERS)
+ bool setFilters(const FilterOperations&);
+#endif
+
void setRootLayer(bool);
WebKit::WebLayerID id() const;
static WebGraphicsLayer* layerByID(WebKit::WebLayerID);
- bool isModified() const { return m_modified; }
void didSynchronize();
Image* image() { return m_image.get(); }
- void notifyAnimationStarted(double);
+
+ bool fixedToViewport() const { return m_fixedToViewport; }
+ void setFixedToViewport(bool isFixed) { m_fixedToViewport = isFixed; }
GraphicsLayer* maskTarget() const { return m_maskTarget; }
void setMaskTarget(GraphicsLayer* layer) { m_maskTarget = layer; }
static void initFactory();
-#if USE(TILED_BACKING_STORE)
// TiledBackingStoreClient
virtual void tiledBackingStorePaintBegin();
virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&);
@@ -129,45 +136,61 @@ public:
virtual Color tiledBackingStoreBackgroundColor() const;
// TiledBackingStoreRemoteTileClient
- virtual void createTile(int tileID, const WebKit::UpdateInfo&);
- virtual void updateTile(int tileID, const WebKit::UpdateInfo&);
+ virtual void createTile(int tileID, const WebKit::SurfaceUpdateInfo&, const WebCore::IntRect&);
+ virtual void updateTile(int tileID, const WebKit::SurfaceUpdateInfo&, const WebCore::IntRect&);
virtual void removeTile(int tileID);
+ virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebKit::ShareableSurface::Handle&, WebCore::IntPoint&);
void setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient*);
+ void syncChildren();
+ void syncLayerState();
+#if ENABLE(CSS_FILTERS)
+ void syncFilters();
+#endif
+ void ensureImageBackingStore();
void adjustVisibleRect();
bool isReadyForTileBufferSwap() const;
void updateContentBuffers();
void purgeBackingStores();
-#endif
private:
+ virtual void willBeDestroyed();
+ WebKit::WebLayerID m_id;
WebKit::WebLayerInfo m_layerInfo;
RefPtr<Image> m_image;
GraphicsLayer* m_maskTarget;
FloatRect m_needsDisplayRect;
LayerTransform m_layerTransform;
- bool m_needsDisplay : 1;
- bool m_modified : 1;
- bool m_contentNeedsDisplay : 1;
- bool m_hasPendingAnimations : 1;
- bool m_inUpdateMode : 2;
+ bool m_inUpdateMode : 1;
+ bool m_shouldUpdateVisibleRect: 1;
+ bool m_shouldSyncLayerState: 1;
+ bool m_shouldSyncChildren: 1;
+ bool m_shouldSyncFilters: 1;
+ bool m_fixedToViewport : 1;
void notifyChange();
- void notifyChangeRecursively();
- void createBackingStore();
- HashSet<String> m_transformAnimations;
+ void didChangeGeometry();
+ void didChangeLayerState();
+ void didChangeChildren();
+#if ENABLE(CSS_FILTERS)
+ void didChangeFilters();
+#endif
- bool selfOrAncestorHasActiveTransformAnimations() const;
+ void createBackingStore();
-#if USE(TILED_BACKING_STORE)
+ bool selfOrAncestorHaveNonAffineTransforms();
+ bool shouldUseTiledBackingStore();
+ void adjustContentsScale();
void computeTransformedVisibleRect();
+ void syncLayerParameters();
+ void setShouldUpdateVisibleRect();
+ float effectiveContentsScale();
WebKit::WebGraphicsLayerClient* m_webGraphicsLayerClient;
OwnPtr<WebCore::TiledBackingStore> m_mainBackingStore;
OwnPtr<WebCore::TiledBackingStore> m_previousBackingStore;
float m_contentsScale;
-#endif
};
WebGraphicsLayer* toWebGraphicsLayer(GraphicsLayer*);
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
index 90a870539..14511856b 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
@@ -53,7 +53,6 @@ void WebInspectorClient::closeInspectorFrontend()
{
if (m_page->inspector()) {
m_page->inspector()->didClose();
- m_page->inspector()->destroyInspectorPage();
}
}
@@ -89,10 +88,19 @@ bool WebInspectorClient::sendMessageToFrontend(const String& message)
WebInspector* inspector = m_page->inspector();
if (!inspector)
return false;
+
+#if ENABLE(INSPECTOR_SERVER)
+ if (inspector->hasRemoteFrontendConnected()) {
+ inspector->sendMessageToRemoteFrontend(message);
+ return true;
+ }
+#endif
+
WebPage* inspectorPage = inspector->inspectorPage();
- if (!inspectorPage)
- return false;
- return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
+ if (inspectorPage)
+ return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
+
+ return false;
}
void WebInspectorClient::pageOverlayDestroyed(PageOverlay*)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp
index 643312440..79bac1ae9 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,7 +26,7 @@
#include "config.h"
#include "WebNotificationClient.h"
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#include "NotificationPermissionRequestManager.h"
#include "WebNotificationManager.h"
@@ -72,10 +72,19 @@ void WebNotificationClient::notificationControllerDestroyed()
delete this;
}
+#if ENABLE(LEGACY_NOTIFICATIONS)
void WebNotificationClient::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
{
m_page->notificationPermissionRequestManager()->startRequest(context->securityOrigin(), callback);
}
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+void WebNotificationClient::requestPermission(ScriptExecutionContext* context, PassRefPtr<NotificationPermissionCallback> callback)
+{
+ m_page->notificationPermissionRequestManager()->startRequest(context->securityOrigin(), callback);
+}
+#endif
void WebNotificationClient::cancelRequestsForPermission(ScriptExecutionContext* context)
{
@@ -91,4 +100,4 @@ NotificationClient::Permission WebNotificationClient::checkPermission(ScriptExec
} // namespace WebKit
-#endif // ENABLE(NOTIFICATIONS)
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h
index 8a84bea1e..de30b0e9e 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,11 +26,12 @@
#ifndef WebNotificationClient_h
#define WebNotificationClient_h
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#include <WebCore/NotificationClient.h>
namespace WebCore {
+class NotificationPermissionCallback;
class ScriptExecutionContext;
class VoidCallback;
} // namespace WebCore
@@ -50,7 +51,12 @@ private:
virtual void clearNotifications(WebCore::ScriptExecutionContext*) OVERRIDE;
virtual void notificationObjectDestroyed(WebCore::Notification*) OVERRIDE;
virtual void notificationControllerDestroyed() OVERRIDE;
+#if ENABLE(LEGACY_NOTIFICATIONS)
virtual void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::VoidCallback>) OVERRIDE;
+#endif
+#if ENABLE(NOTIFICATIONS)
+ virtual void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::NotificationPermissionCallback>) OVERRIDE;
+#endif
virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) OVERRIDE;
virtual NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) OVERRIDE;
@@ -59,6 +65,6 @@ private:
} // namespace WebKit
-#endif // ENABLE(NOTIFICATIONS)
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#endif // WebNotificationClient_h
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
index 1914efcbe..6622cf617 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
@@ -34,6 +34,7 @@
#include "WebCoreArgumentCoders.h"
#include "WebProcess.h"
#include <WebCore/Color.h>
+#include <WebCore/KURL.h>
#include <WebCore/Page.h>
#include <WebCore/PlatformPasteboard.h>
@@ -155,11 +156,8 @@ PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const Str
void WebPlatformStrategies::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
{
- // FIXME: this needs to be replaced with the code below, once we resolve the sandboxing issue.
- // WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardPathnamesForType(pasteboardName, pasteboardType),
- // Messages::WebContext::GetPasteboardPathnamesForType::Reply(pathnames), 0);
-
- PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType);
+ WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardPathnamesForType(pasteboardName, pasteboardType),
+ Messages::WebContext::GetPasteboardPathnamesForType::Reply(pathnames), 0);
}
String WebPlatformStrategies::stringForType(const String& pasteboardType, const String& pasteboardName)
@@ -199,6 +197,19 @@ Color WebPlatformStrategies::color(const String& pasteboardName)
return color;
}
+KURL WebPlatformStrategies::url(const String& pasteboardName)
+{
+ String urlString;
+ WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardURL(pasteboardName),
+ Messages::WebContext::GetPasteboardURL::Reply(urlString), 0);
+ return KURL(ParsedURLString, urlString);
+}
+
+void WebPlatformStrategies::addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
+{
+ WebProcess::shared().connection()->send(Messages::WebContext::AddPasteboardTypes(pasteboardName, pasteboardTypes), 0);
+}
+
void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
{
WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes), 0);
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
index e8e9bf790..086fd0afd 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
@@ -70,8 +70,10 @@ private:
virtual int changeCount(const String& pasteboardName) OVERRIDE;
virtual String uniqueName() OVERRIDE;
virtual WebCore::Color color(const String& pasteboardName) OVERRIDE;
-
+ virtual WebCore::KURL url(const String& pasteboardName) OVERRIDE;
+
virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
+ virtual void addTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
virtual void setBufferForType(PassRefPtr<WebCore::SharedBuffer>, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
virtual void setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) OVERRIDE;
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebContextMenuClientEfl.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebContextMenuClientEfl.cpp
index 62d7b847f..0b010efdc 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebContextMenuClientEfl.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebContextMenuClientEfl.cpp
@@ -24,6 +24,9 @@
*/
#include "config.h"
+
+#if ENABLE(CONTEXT_MENUS)
+
#include "WebContextMenuClient.h"
#include <WebCore/NotImplemented.h>
@@ -54,3 +57,4 @@ void WebContextMenuClient::stopSpeaking()
}
} // namespace WebKit
+#endif // ENABLE(CONTEXT_MENUS)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
index 9f3453067..e33d72327 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
@@ -194,5 +194,9 @@ void WebEditorClient::setSelectionPrimaryClipboardIfNeeded(Frame* frame)
#endif
}
+bool WebEditorClient::shouldShowUnicodeMenu()
+{
+ return true;
+}
}
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp
new file mode 100644
index 000000000..ac1dfc583
--- /dev/null
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebAlternativeTextClient.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAlternativeTextClient.h"
+
+#include "WebCoreArgumentCoders.h"
+#include "WebPage.h"
+#include "WebPageProxyMessages.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebAlternativeTextClient::WebAlternativeTextClient(WebPage* webPage)
+: m_page(webPage)
+{
+}
+
+WebAlternativeTextClient::~WebAlternativeTextClient()
+{
+#if USE(AUTOCORRECTION_PANEL)
+ m_page->send(Messages::WebPageProxy::DismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored));
+#endif
+}
+
+void WebAlternativeTextClient::pageDestroyed()
+{
+ delete this;
+}
+
+void WebAlternativeTextClient::showCorrectionAlternative(AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
+{
+#if USE(AUTOCORRECTION_PANEL)
+ m_page->send(Messages::WebPageProxy::ShowCorrectionPanel(type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings));
+#endif
+}
+
+void WebAlternativeTextClient::dismissAlternative(ReasonForDismissingAlternativeText reason)
+{
+#if USE(AUTOCORRECTION_PANEL)
+ m_page->send(Messages::WebPageProxy::DismissCorrectionPanel(reason));
+#endif
+}
+
+String WebAlternativeTextClient::dismissAlternativeSoon(ReasonForDismissingAlternativeText reason)
+{
+ String result;
+#if USE(AUTOCORRECTION_PANEL)
+ m_page->sendSync(Messages::WebPageProxy::DismissCorrectionPanelSoon(reason), Messages::WebPageProxy::DismissCorrectionPanelSoon::Reply(result));
+#endif
+ return result;
+}
+
+void WebAlternativeTextClient::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
+{
+#if USE(AUTOCORRECTION_PANEL)
+ m_page->send(Messages::WebPageProxy::RecordAutocorrectionResponse(responseType, replacedString, replacementString));
+#endif
+}
+
+}
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
index da608ddfb..1bb209d2e 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
@@ -54,28 +54,6 @@
using namespace WebCore;
using namespace WebKit;
-// Internal AppKit class. If the pasteboard handling was in the same process
-// that called the dragImage method, this would be created automatically.
-// Create it explicitly because dragImage is called in the UI process.
-@interface NSFilePromiseDragSource : NSObject
-{
- id _dragSource;
- char _unknownFields[256];
-}
-- (id)initWithSource:(id)dragSource;
-- (void)setTypes:(NSArray *)types onPasteboard:(NSPasteboard *)pasteboard;
-@end
-
-@interface WKPasteboardFilePromiseOwner : NSFilePromiseDragSource
-@end
-
-@interface WKPasteboardOwner : NSObject
-{
- CachedResourceHandle<WebCore::CachedImage> _image;
-}
-- (id)initWithImage:(WebCore::CachedImage*)image;
-@end
-
namespace WebKit {
static PassRefPtr<ShareableBitmap> convertImageToBitmap(NSImage *image, const IntSize& size)
@@ -119,12 +97,6 @@ static WebCore::CachedImage* cachedImage(Element* element)
return image;
}
-static NSArray *arrayForURLsWithTitles(NSURL *URL, NSString *title)
-{
- return [NSArray arrayWithObjects:[NSArray arrayWithObject:[URL _web_originalDataAsString]],
- [NSArray arrayWithObject:[title _webkit_stringByTrimmingWhitespace]], nil];
-}
-
void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMElement *element, NSURL *URL, NSString *title, WebCore::Frame*)
{
ASSERT(element);
@@ -149,190 +121,27 @@ void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, DOMEl
RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreElement);
- RetainPtr<NSMutableArray> types(AdoptNS, [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]);
- [types.get() addObjectsFromArray:archive ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()];
-
- m_pasteboardOwner.adoptNS([[WKPasteboardOwner alloc] initWithImage:image]);
- m_filePromiseOwner.adoptNS([(WKPasteboardFilePromiseOwner *)[WKPasteboardFilePromiseOwner alloc] initWithSource:m_pasteboardOwner.get()]);
-
- NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:pasteboardName];
- [pasteboard declareTypes:types.get() owner:m_pasteboardOwner.leakRef()];
-
- [pasteboard setPropertyList:[NSArray arrayWithObject:extension] forType:NSFilesPromisePboardType];
-
- [m_filePromiseOwner.get() setTypes:[pasteboard propertyListForType:NSFilesPromisePboardType] onPasteboard:pasteboard];
-
- [URL writeToPasteboard:pasteboard];
-
- [pasteboard setString:[URL _web_originalDataAsString] forType:PasteboardTypes::WebURLPboardType];
-
- [pasteboard setString:title forType:PasteboardTypes::WebURLNamePboardType];
-
- [pasteboard setString:[URL _web_userVisibleString] forType:NSStringPboardType];
-
- [pasteboard setPropertyList:arrayForURLsWithTitles(URL, title) forType:PasteboardTypes::WebURLsWithTitlesPboardType];
-
- if (archive)
- [pasteboard setData:(NSData *)archive->rawDataRepresentation().get() forType:PasteboardTypes::WebArchivePboardType];
-}
-
-void WebDragClient::dragEnded()
-{
- // The draggedImage method releases its responder; we must retain the WKPasteboardFilePromiseOwner an extra time to balance the release
- // inside of the function.
- [m_filePromiseOwner.get() retain];
-
- // The drag source we care about here is NSFilePromiseDragSource, which doesn't look at
- // the arguments. It's OK to just pass arbitrary constant values, so we just pass all zeroes.
- [m_filePromiseOwner.get() draggedImage:nil endedAt:NSZeroPoint operation:NSDragOperationNone];
+ NSURLResponse *response = image->response().nsURLResponse();
- m_pasteboardOwner = nullptr;
- m_filePromiseOwner = nullptr;
-}
-
-} // namespace WebKit
-
-@implementation WKPasteboardFilePromiseOwner
-
-- (id)initWithSource:(id)dragSource
-{
- self = [super initWithSource:dragSource];
- if (!self)
- return nil;
- [_dragSource retain];
- return self;
-}
-
-- (void)dealloc
-{
- [_dragSource release];
- [super dealloc];
-}
-
-// The AppKit implementation of copyDropDirectory gets the current pasteboard in
-// a way that only works in the process where the drag is initiated. We supply
-// an implementation that gets the pasteboard by name instead.
-- (CFURLRef)copyDropDirectory
-{
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate((CFStringRef)NSDragPboard, &pasteboard);
- if (status != noErr || !pasteboard)
- return 0;
- CFURLRef location = 0;
- status = PasteboardCopyPasteLocation(pasteboard, &location);
- CFRelease(pasteboard);
- if (status != noErr || !location)
- return 0;
- CFMakeCollectable(location);
- return location;
-}
-
-@end
-
-@implementation WKPasteboardOwner
-
-static CachedImageClient* promisedDataClient()
-{
- static CachedImageClient* client = new CachedImageClient;
- return client;
-}
-
-- (void)clearImage
-{
- if (!_image)
- return;
- _image->removeClient(promisedDataClient());
- _image = 0;
-}
-
-- (id)initWithImage:(WebCore::CachedImage*)image
-{
- self = [super init];
- if (!self)
- return nil;
-
- _image = image;
- if (image)
- image->addClient(promisedDataClient());
- return self;
-}
-
-- (void)dealloc
-{
- [self clearImage];
- [super dealloc];
-}
-
-- (void)finalize
-{
- [self clearImage];
- [super finalize];
-}
-
-- (void)pasteboard:(NSPasteboard *)pasteboard provideDataForType:(NSString *)type
-{
- if ([type isEqual:NSTIFFPboardType]) {
- if (_image) {
- if (Image* image = _image->image())
- [pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType];
- [self clearImage];
- }
- return;
- }
- // FIXME: Handle RTFD here.
-}
-
-- (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard
-{
- [self clearImage];
- CFRelease(self); // Balanced by the leakRef that WebDragClient::declareAndWriteDragImage does when making this pasteboard owner.
-}
-
-static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension)
-{
- NSString *extensionAsSuffix = [@"." stringByAppendingString:extension];
- return [filename _webkit_hasCaseInsensitiveSuffix:extensionAsSuffix]
- || ([extension _webkit_isCaseInsensitiveEqualToString:@"jpeg"]
- && [filename _webkit_hasCaseInsensitiveSuffix:@".jpg"]);
-}
-
-- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
-{
- NSFileWrapper *wrapper = nil;
- NSURL *draggingImageURL = nil;
+ RefPtr<SharedBuffer> imageBuffer = image->image()->data();
+ size_t imageSize = imageBuffer->size();
+ SharedMemory::Handle imageHandle;
- if (_image) {
- if (SharedBuffer* buffer = _image->CachedResource::data()) {
- NSData *data = buffer->createNSData();
- NSURLResponse *response = _image->response().nsURLResponse();
- draggingImageURL = [response URL];
- wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
- NSString* filename = [response suggestedFilename];
- NSString* trueExtension(_image->image()->filenameExtension());
- if (!matchesExtensionOrEquivalent(filename, trueExtension))
- filename = [[filename stringByAppendingString:@"."] stringByAppendingString:trueExtension];
- [wrapper setPreferredFilename:filename];
- }
- }
-
- // FIXME: Do we need to handle the case where we do not have a CachedImage?
- // WebKit1 had code for this case.
+ RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(imageBuffer->size());
+ memcpy(sharedMemoryBuffer->data(), imageBuffer->data(), imageSize);
+ sharedMemoryBuffer->createHandle(imageHandle, SharedMemory::ReadOnly);
- if (!wrapper) {
- LOG_ERROR("Failed to create image file.");
- return nil;
+ RetainPtr<CFDataRef> data = archive ? archive->rawDataRepresentation() : 0;
+ SharedMemory::Handle archiveHandle;
+ size_t archiveSize = 0;
+ if (data) {
+ RefPtr<SharedBuffer> buffer = SharedBuffer::wrapNSData((NSData *)data.get());
+ RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(buffer->size());
+ archiveSize = buffer->size();
+ memcpy(sharedMemoryBuffer->data(), buffer->data(), archiveSize);
+ sharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly);
}
-
- // FIXME: Report an error if we fail to create a file.
- NSString *path = [[dropDestination path] stringByAppendingPathComponent:[wrapper preferredFilename]];
- path = [[NSFileManager defaultManager] _webkit_pathWithUniqueFilenameForPath:path];
- if (![wrapper writeToFile:path atomically:NO updateFilenames:YES])
- LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToFile:atomically:updateFilenames:] at path %@", path);
-
- if (draggingImageURL)
- [[NSFileManager defaultManager] _webkit_setMetadataURL:[draggingImageURL absoluteString] referrer:nil atPath:path];
-
- return [NSArray arrayWithObject:[path lastPathComponent]];
+ m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), String(extension), String(title), String([[response URL] absoluteString]), String([URL _web_userVisibleString]), archiveHandle, archiveSize));
}
-@end
+} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
index 523cbdf72..651d0dd8f 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
@@ -238,28 +238,4 @@ void WebEditorClient::checkTextOfParagraph(const UChar* text, int length, WebCor
m_page->sendSync(Messages::WebPageProxy::CheckTextOfParagraph(String(text, length), checkingTypes), Messages::WebPageProxy::CheckTextOfParagraph::Reply(results));
}
-#if !defined(BUILDING_ON_SNOW_LEOPARD)
-void WebEditorClient::showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType type, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
-{
- m_page->send(Messages::WebPageProxy::ShowCorrectionPanel(type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings));
-}
-
-void WebEditorClient::dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel reason)
-{
- m_page->send(Messages::WebPageProxy::DismissCorrectionPanel(reason));
-}
-
-String WebEditorClient::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel reason)
-{
- String result;
- m_page->sendSync(Messages::WebPageProxy::DismissCorrectionPanelSoon(reason), Messages::WebPageProxy::DismissCorrectionPanelSoon::Reply(result));
- return result;
-}
-
-void WebEditorClient::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
-{
- m_page->send(Messages::WebPageProxy::RecordAutocorrectionResponse(responseType, replacedString, replacementString));
-}
-#endif
-
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
index bfc7da53a..37a684143 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
@@ -115,6 +115,8 @@ void InitWebCoreSystemInterface(void)
INIT(SetHTTPCookiesForURL);
INIT(DeleteHTTPCookie);
+ INIT(SetMetadataURL);
+
#if !defined(BUILDING_ON_SNOW_LEOPARD)
INIT(IOSurfaceContextCreate);
INIT(IOSurfaceContextCreateImage);
@@ -165,5 +167,18 @@ void InitWebCoreSystemInterface(void)
INIT(ExecutableWasLinkedOnOrBeforeLion);
#endif
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ INIT(CGPathAddRoundedRect);
+#endif
+
+#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION) && !PLATFORM(IOS)
+ INIT(FilterIsManagedSession);
+ INIT(FilterCreateInstance);
+ INIT(FilterRelease);
+ INIT(FilterWasBlocked);
+ INIT(FilterAddData);
+ INIT(FilterDataComplete);
+#endif
+
});
}
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
new file mode 100644
index 000000000..876de80a6
--- /dev/null
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
@@ -0,0 +1,41 @@
+/*
+ * 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 "WebFrameNetworkingContext.h"
+
+#include <WebCore/ResourceHandle.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+SoupSession* WebFrameNetworkingContext::soupSession() const
+{
+ return ResourceHandle::defaultSession();
+}
+
+}
+
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h
index d67be5d4a..2a42d38d3 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * 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
@@ -31,23 +32,24 @@
#include <WebCore/FrameNetworkingContext.h>
+namespace WebKit {
+
class WebFrameNetworkingContext : public WebCore::FrameNetworkingContext {
public:
- static PassRefPtr<WebFrameNetworkingContext> create(WebKit::WebFrame*)
+ static PassRefPtr<WebFrameNetworkingContext> create(WebFrame* frame)
{
- return 0;
+ return adoptRef(new WebFrameNetworkingContext(frame));
}
private:
- WebFrameNetworkingContext(WebKit::WebFrame* frame)
+ WebFrameNetworkingContext(WebFrame* frame)
: WebCore::FrameNetworkingContext(frame->coreFrame())
{
}
- virtual WTF::String userAgent() const;
- virtual WTF::String referrer() const;
-
- WTF::String m_userAgent;
+ virtual SoupSession* soupSession() const;
};
+}
+
#endif // WebFrameNetworkingContext_h
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
index 7427f118a..eae9393f3 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
@@ -29,6 +29,7 @@
#include "PlatformPopupMenuData.h"
#include <WebCore/Font.h>
#include <WebCore/GraphicsContext.h>
+#include <WebCore/LengthFunctions.h>
#include <WebCore/TextRun.h>
#include <WebCore/PopupMenuClient.h>
#include <WebCore/PopupMenuStyle.h>
@@ -135,7 +136,7 @@ void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, Pl
if (itemStyle.isVisible()) {
int textX = std::max(0, data.m_clientPaddingLeft - data.m_clientInsetLeft);
if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR)
- textX += itemStyle.textIndent().calcMinValue(itemRect.width());
+ textX += minimumIntValueForLength(itemStyle.textIndent(), itemRect.width());
int textY = itemRect.y() + itemFont.fontMetrics().ascent() + (itemRect.height() - itemFont.fontMetrics().height()) / 2;
notSelectedBackingStoreContext->drawBidiText(itemFont, textRun, IntPoint(textX, textY));
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp
index 841e35ab8..11e893faf 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp
@@ -29,7 +29,7 @@
// Subclasses
#include "DrawingAreaImpl.h"
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) && ENABLE(THREADED_SCROLLING)
#include "TiledCoreAnimationDrawingArea.h"
#endif
@@ -42,7 +42,7 @@ PassOwnPtr<DrawingArea> DrawingArea::create(WebPage* webPage, const WebPageCreat
switch (parameters.drawingAreaType) {
case DrawingAreaTypeImpl:
return DrawingAreaImpl::create(webPage, parameters);
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) && ENABLE(THREADED_SCROLLING)
case DrawingAreaTypeTiledCoreAnimation:
return TiledCoreAnimationDrawingArea::create(webPage, parameters);
#endif
@@ -61,4 +61,10 @@ DrawingArea::~DrawingArea()
{
}
+void DrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& function)
+{
+ // Scroll position updates are synchronous by default so we can just call the function right away here.
+ function();
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h
index 2ee6557ea..30026e72f 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h
@@ -29,6 +29,7 @@
#include "DrawingAreaInfo.h"
#include <WebCore/FloatPoint.h>
#include <WebCore/IntRect.h>
+#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
@@ -44,6 +45,7 @@ namespace WebCore {
namespace WebKit {
+class LayerTreeHost;
class WebPage;
struct WebPageCreationParameters;
@@ -69,13 +71,18 @@ public:
virtual bool forceRepaintAsync(uint64_t callbackID) { return false; }
virtual void setLayerTreeStateIsFrozen(bool) { }
virtual bool layerTreeStateIsFrozen() const { return false; }
+ virtual LayerTreeHost* layerTreeHost() const { return 0; }
virtual void didInstallPageOverlay() { }
virtual void didUninstallPageOverlay() { }
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) { }
+ virtual void setPageOverlayOpacity(float) { }
+ // If this function returns false, PageOverlay should apply opacity when painting.
+ virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return true; }
virtual void pageCustomRepresentationChanged() { }
virtual void setPaintingEnabled(bool) { }
+ virtual void updatePreferences() { }
#if USE(ACCELERATED_COMPOSITING)
virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
@@ -90,6 +97,8 @@ public:
virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
#endif
+ virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&);
+
protected:
DrawingArea(DrawingAreaType, WebPage*);
@@ -103,12 +112,12 @@ private:
virtual void didUpdate() { }
virtual void suspendPainting() { }
virtual void resumePainting() { }
+ virtual void setLayerHostingMode(uint32_t) { }
#if PLATFORM(MAC)
// Used by TiledCoreAnimationDrawingArea.
virtual void updateGeometry(const WebCore::IntSize& viewSize) { }
virtual void setDeviceScaleFactor(float) { }
- virtual void setLayerHostingMode(uint32_t) { }
#endif
};
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in b/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
index 0d92a4986..9de81139c 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
@@ -26,11 +26,11 @@ messages -> DrawingArea {
SuspendPainting()
ResumePainting()
PageCustomRepresentationChanged()
+ SetLayerHostingMode(uint32_t layerHostingMode)
#if PLATFORM(MAC)
// Used by TiledCoreAnimationDrawingArea.
UpdateGeometry(WebCore::IntSize viewSize)
SetDeviceScaleFactor(float deviceScaleFactor)
- SetLayerHostingMode(uint32_t layerHostingMode)
#endif
}
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
index 619b814a9..d710e99ec 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
@@ -223,6 +223,20 @@ void DrawingAreaImpl::setPageOverlayNeedsDisplay(const IntRect& rect)
setNeedsDisplay(rect);
}
+void DrawingAreaImpl::setPageOverlayOpacity(float value)
+{
+ if (m_layerTreeHost)
+ m_layerTreeHost->setPageOverlayOpacity(value);
+}
+
+bool DrawingAreaImpl::pageOverlayShouldApplyFadeWhenPainting() const
+{
+ if (m_layerTreeHost && !m_layerTreeHost->pageOverlayShouldApplyFadeWhenPainting())
+ return false;
+
+ return true;
+}
+
void DrawingAreaImpl::pageCustomRepresentationChanged()
{
if (!m_alwaysUseCompositing)
@@ -327,7 +341,9 @@ void DrawingAreaImpl::updateBackingStoreState(uint64_t stateID, bool respondImme
if (m_layerTreeHost) {
m_layerTreeHost->deviceScaleFactorDidChange();
- m_layerTreeHost->sizeDidChange(size);
+ // Use the previously set page size instead of the argument.
+ // It gets adjusted properly when using the fixed layout mode.
+ m_layerTreeHost->sizeDidChange(m_webPage->size());
} else
m_dirtyRegion = m_webPage->bounds();
} else {
@@ -434,7 +450,12 @@ void DrawingAreaImpl::resumePainting()
// FIXME: We shouldn't always repaint everything here.
setNeedsDisplay(m_webPage->bounds());
+#if PLATFORM(MAC)
+ if (m_webPage->windowIsVisible())
+ m_webPage->corePage()->resumeScriptedAnimations();
+#else
m_webPage->corePage()->resumeScriptedAnimations();
+#endif
}
void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
@@ -675,5 +696,17 @@ void DrawingAreaImpl::didReceiveLayerTreeHostMessage(CoreIPC::Connection* connec
}
#endif
+#if PLATFORM(MAC)
+void DrawingAreaImpl::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
+{
+ LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
+ m_webPage->setLayerHostingMode(layerHostingMode);
+
+ if (!m_layerTreeHost)
+ return;
+
+ m_layerTreeHost->setLayerHostingMode(layerHostingMode);
+}
+#endif
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
index 2f99c337f..39d0515b5 100644
--- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
+++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h
@@ -55,11 +55,14 @@ private:
virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
virtual void setLayerTreeStateIsFrozen(bool);
virtual bool layerTreeStateIsFrozen() const { return m_layerTreeStateIsFrozen; }
+ virtual LayerTreeHost* layerTreeHost() const { return m_layerTreeHost.get(); }
virtual void forceRepaint();
virtual void didInstallPageOverlay();
virtual void didUninstallPageOverlay();
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&);
+ virtual void setPageOverlayOpacity(float);
+ virtual bool pageOverlayShouldApplyFadeWhenPainting() const;
virtual void setPaintingEnabled(bool);
@@ -70,6 +73,10 @@ private:
virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&);
#endif
+#if PLATFORM(MAC)
+ virtual void setLayerHostingMode(uint32_t) OVERRIDE;
+#endif
+
#if USE(UI_SIDE_COMPOSITING)
virtual void didReceiveLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
#endif
diff --git a/Source/WebKit2/WebProcess/WebPage/FindController.cpp b/Source/WebKit2/WebProcess/WebPage/FindController.cpp
index 6b6156934..4918dde36 100644
--- a/Source/WebKit2/WebProcess/WebPage/FindController.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/FindController.cpp
@@ -33,6 +33,7 @@
#include "WebPageProxyMessages.h"
#include "WebProcess.h"
#include <WebCore/DocumentMarkerController.h>
+#include <WebCore/FloatQuad.h>
#include <WebCore/FocusController.h>
#include <WebCore/Frame.h>
#include <WebCore/FrameView.h>
@@ -89,12 +90,8 @@ static Frame* frameWithSelection(Page* page)
return 0;
}
-void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+void FindController::updateFindUIAfterPageScroll(bool found, const String& string, FindOptions options, unsigned maxMatchCount)
{
- m_webPage->corePage()->unmarkAllTextMatches();
-
- bool found = m_webPage->corePage()->findString(string, core(options));
-
Frame* selectedFrame = frameWithSelection(m_webPage->corePage());
bool shouldShowOverlay = false;
@@ -141,19 +138,27 @@ void FindController::findString(const String& string, FindOptions options, unsig
}
ASSERT(!m_findPageOverlay);
- return;
- }
-
- if (!m_findPageOverlay) {
- RefPtr<PageOverlay> findPageOverlay = PageOverlay::create(this);
- m_findPageOverlay = findPageOverlay.get();
- m_webPage->installPageOverlay(findPageOverlay.release());
} else {
- // The page overlay needs to be repainted.
- m_findPageOverlay->setNeedsDisplay();
+ if (!m_findPageOverlay) {
+ RefPtr<PageOverlay> findPageOverlay = PageOverlay::create(this);
+ m_findPageOverlay = findPageOverlay.get();
+ m_webPage->installPageOverlay(findPageOverlay.release());
+ } else {
+ // The page overlay needs to be repainted.
+ m_findPageOverlay->setNeedsDisplay();
+ }
}
}
+void FindController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ m_webPage->corePage()->unmarkAllTextMatches();
+
+ bool found = m_webPage->corePage()->findString(string, core(options));
+
+ m_webPage->drawingArea()->dispatchAfterEnsuringUpdatedScrollPosition(bind(&FindController::updateFindUIAfterPageScroll, this, found, string, options, maxMatchCount));
+}
+
void FindController::hideFindUI()
{
if (m_findPageOverlay)
@@ -216,6 +221,7 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
}
m_webPage->send(Messages::WebPageProxy::SetFindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, m_webPage->corePage()->deviceScaleFactor(), handle, !isShowingOverlay, shouldAnimate));
+ m_findIndicatorRect = selectionRectInWindowCoordinates;
m_isShowingFindIndicator = true;
return true;
@@ -347,6 +353,16 @@ void FindController::drawRect(PageOverlay* pageOverlay, GraphicsContext& graphic
// Clear out the holes.
for (size_t i = 0; i < rects.size(); ++i)
graphicsContext.fillRect(rects[i]);
+
+ if (!m_isShowingFindIndicator)
+ return;
+
+ if (Frame* selectedFrame = frameWithSelection(m_webPage->corePage())) {
+ IntRect findIndicatorRect = selectedFrame->view()->contentsToWindow(enclosingIntRect(selectedFrame->selection()->bounds()));
+
+ if (findIndicatorRect != m_findIndicatorRect)
+ hideFindIndicator();
+ }
}
bool FindController::mouseEvent(PageOverlay* pageOverlay, const WebMouseEvent& mouseEvent)
diff --git a/Source/WebKit2/WebProcess/WebPage/FindController.h b/Source/WebKit2/WebProcess/WebPage/FindController.h
index da03b79a7..e070b6b73 100644
--- a/Source/WebKit2/WebProcess/WebPage/FindController.h
+++ b/Source/WebKit2/WebProcess/WebPage/FindController.h
@@ -28,13 +28,13 @@
#include "PageOverlay.h"
#include "WebFindOptions.h"
+#include <WebCore/IntRect.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
namespace WebCore {
class Frame;
- class IntRect;
}
namespace WebKit {
@@ -70,13 +70,15 @@ private:
Vector<WebCore::IntRect> rectsForTextMatches();
bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
-private:
+ void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount);
+
WebPage* m_webPage;
PageOverlay* m_findPageOverlay;
// Whether the UI process is showing the find indicator. Note that this can be true even if
// the find indicator isn't showing, but it will never be false when it is showing.
bool m_isShowingFindIndicator;
+ WebCore::IntRect m_findIndicatorRect;
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
index 6f336a5cd..e503c2371 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
@@ -26,6 +26,7 @@
#ifndef LayerTreeHost_h
#define LayerTreeHost_h
+#include "LayerTreeContext.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -44,7 +45,6 @@ class GraphicsLayer;
namespace WebKit {
-class LayerTreeContext;
class UpdateInfo;
class WebPage;
@@ -75,13 +75,14 @@ public:
virtual void didInstallPageOverlay() = 0;
virtual void didUninstallPageOverlay() = 0;
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) = 0;
+ virtual void setPageOverlayOpacity(float) { }
+ virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return true; }
virtual void pauseRendering() { }
virtual void resumeRendering() { }
-#if USE(TILED_BACKING_STORE)
- virtual void setVisibleContentsRectForScaling(const WebCore::IntRect&, float scale) { }
- virtual void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&) { }
+#if USE(UI_SIDE_COMPOSITING)
+ virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&) { }
virtual void setVisibleContentsRectForLayer(int layerID, const WebCore::IntRect&) { }
virtual void renderNextFrame() { }
virtual void purgeBackingStores() { }
@@ -92,13 +93,16 @@ public:
virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
#endif
+#if PLATFORM(MAC)
+ virtual void setLayerHostingMode(LayerHostingMode) { }
+#endif
+
protected:
explicit LayerTreeHost(WebPage*);
WebPage* m_webPage;
-
-#if USE(TILED_BACKING_STORE)
+#if USE(UI_SIDE_COMPOSITING)
bool m_waitingForUIProcess;
#endif
};
diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
index 70fa85841..8920de27f 100644
--- a/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
+++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
@@ -20,8 +20,7 @@
#if USE(TILED_BACKING_STORE)
messages -> LayerTreeHost {
- SetVisibleContentsRectForPanning(WebCore::IntRect visibleContentsRect, WebCore::FloatPoint trajectoryVectory)
- SetVisibleContentsRectForScaling(WebCore::IntRect visibleContentsRect, float scale)
+ SetVisibleContentsRect(WebCore::IntRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory)
RenderNextFrame()
PurgeBackingStores()
}
diff --git a/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp b/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp
index aa32b6a09..2b42477b0 100644
--- a/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp
@@ -54,6 +54,7 @@ PageOverlay::PageOverlay(Client* client)
, m_fadeAnimationDuration(fadeAnimationDuration)
, m_fadeAnimationType(NoAnimation)
, m_fractionFadedIn(1.0)
+ , m_pageOverlayShouldApplyFadeWhenPainting(true)
{
}
@@ -83,13 +84,19 @@ void PageOverlay::setPage(WebPage* webPage)
m_webPage = webPage;
m_client->didMoveToWebPage(this, webPage);
+ if (m_webPage)
+ m_pageOverlayShouldApplyFadeWhenPainting = m_webPage->drawingArea()->pageOverlayShouldApplyFadeWhenPainting();
+
m_fadeAnimationTimer.stop();
}
void PageOverlay::setNeedsDisplay(const IntRect& dirtyRect)
{
- if (m_webPage)
+ if (m_webPage) {
+ if (!m_pageOverlayShouldApplyFadeWhenPainting)
+ m_webPage->drawingArea()->setPageOverlayOpacity(m_fractionFadedIn);
m_webPage->drawingArea()->setPageOverlayNeedsDisplay(dirtyRect);
+ }
}
void PageOverlay::setNeedsDisplay()
@@ -157,7 +164,11 @@ void PageOverlay::fadeAnimationTimerFired()
float fadeAnimationValue = sine * sine;
m_fractionFadedIn = (m_fadeAnimationType == FadeInAnimation) ? fadeAnimationValue : 1 - fadeAnimationValue;
- setNeedsDisplay();
+
+ if (m_pageOverlayShouldApplyFadeWhenPainting)
+ setNeedsDisplay();
+ else
+ m_webPage->drawingArea()->setPageOverlayOpacity(m_fractionFadedIn);
if (animationProgress == 1.0) {
m_fadeAnimationTimer.stop();
diff --git a/Source/WebKit2/WebProcess/WebPage/PageOverlay.h b/Source/WebKit2/WebProcess/WebPage/PageOverlay.h
index 949767806..e2434807f 100644
--- a/Source/WebKit2/WebProcess/WebPage/PageOverlay.h
+++ b/Source/WebKit2/WebProcess/WebPage/PageOverlay.h
@@ -98,6 +98,7 @@ private:
FadeAnimationType m_fadeAnimationType;
float m_fractionFadedIn;
+ bool m_pageOverlayShouldApplyFadeWhenPainting;
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp b/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp
index 725324703..82af01d73 100644
--- a/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/TapHighlightController.cpp
@@ -102,11 +102,12 @@ void TapHighlightController::drawRect(PageOverlay* pageOverlay, GraphicsContext&
if (m_path.isEmpty())
return;
- float fractionFadedIn = pageOverlay->fractionFadedIn();
-
{
GraphicsContextStateSaver stateSaver(context);
- context.setFillColor(highlightColor(m_color, fractionFadedIn), ColorSpaceSRGB);
+ if (m_webPage->drawingArea()->pageOverlayShouldApplyFadeWhenPainting())
+ context.setFillColor(highlightColor(m_color, pageOverlay->fractionFadedIn()), ColorSpaceSRGB);
+ else
+ context.setFillColor(m_color, ColorSpaceSRGB);
context.fillPath(m_path);
}
}
diff --git a/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp b/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp
index ee116c2e9..2125600b1 100644
--- a/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp
@@ -30,8 +30,8 @@
#include "GraphicsContext.h"
#include "ImageBuffer.h"
+#include "SurfaceUpdateInfo.h"
#include "TiledBackingStoreClient.h"
-#include "UpdateInfo.h"
using namespace WebCore;
@@ -72,26 +72,25 @@ Vector<IntRect> TiledBackingStoreRemoteTile::updateBackBuffer()
if (!isDirty())
return Vector<IntRect>();
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_dirtyRect.size(), m_tiledBackingStore->supportsAlpha() ? ShareableBitmap::SupportsAlpha : 0);
- OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext());
+ SurfaceUpdateInfo updateInfo;
+ OwnPtr<GraphicsContext> graphicsContext = m_client->beginContentUpdate(m_dirtyRect.size(), updateInfo.surfaceHandle, updateInfo.surfaceOffset);
+ if (!graphicsContext)
+ return Vector<IntRect>();
graphicsContext->translate(-m_dirtyRect.x(), -m_dirtyRect.y());
graphicsContext->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale()));
m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(m_dirtyRect));
- UpdateInfo updateInfo;
- updateInfo.updateRectBounds = m_rect;
- IntRect updateRect = m_dirtyRect;
- updateRect.move(-m_rect.x(), -m_rect.y());
- updateInfo.updateRects.append(updateRect);
- updateInfo.updateScaleFactor = m_tiledBackingStore->contentsScale();
- bitmap->createHandle(updateInfo.bitmapHandle);
+ updateInfo.updateRect = m_dirtyRect;
+ updateInfo.updateRect.move(-m_rect.x(), -m_rect.y());
+ updateInfo.scaleFactor = m_tiledBackingStore->contentsScale();
+ graphicsContext.release();
static int id = 0;
if (!m_ID) {
m_ID = ++id;
- m_client->createTile(m_ID, updateInfo);
+ m_client->createTile(m_ID, updateInfo, m_rect);
} else
- m_client->updateTile(m_ID, updateInfo);
+ m_client->updateTile(m_ID, updateInfo, m_rect);
m_dirtyRect = IntRect();
return Vector<IntRect>();
diff --git a/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h b/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h
index 12b2e0602..cae11e9bb 100644
--- a/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h
+++ b/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h
@@ -28,6 +28,7 @@
#if USE(TILED_BACKING_STORE)
+#include "ShareableSurface.h"
#include "Tile.h"
#include "TiledBackingStore.h"
#include "WebCore/IntRect.h"
@@ -40,7 +41,7 @@ class TiledBackingStore;
namespace WebKit {
class TiledBackingStoreRemoteTileClient;
-class UpdateInfo;
+class SurfaceUpdateInfo;
class TiledBackingStoreRemoteTile : public WebCore::Tile {
public:
@@ -75,9 +76,10 @@ private:
class TiledBackingStoreRemoteTileClient {
public:
virtual ~TiledBackingStoreRemoteTileClient() { }
- virtual void createTile(int tileID, const UpdateInfo&) = 0;
- virtual void updateTile(int tileID, const UpdateInfo&) = 0;
+ virtual void createTile(int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
+ virtual void updateTile(int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
virtual void removeTile(int tileID) = 0;
+ virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableSurface::Handle&, WebCore::IntPoint&) = 0;
};
class TiledBackingStoreRemoteTileBackend : public WebCore::TiledBackingStoreBackend {
diff --git a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp
new file mode 100644
index 000000000..9383bc52d
--- /dev/null
+++ b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp
@@ -0,0 +1,140 @@
+/*
+ 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 library 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 library; 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 "UpdateAtlas.h"
+
+#if USE(UI_SIDE_COMPOSITING)
+
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include "MathExtras.h"
+using namespace WebCore;
+
+namespace WebKit {
+
+UpdateAtlas::UpdateAtlas(int dimension, ShareableBitmap::Flags flags)
+ : m_flags(flags)
+{
+ m_surface = ShareableSurface::create(IntSize(dimension, dimension), flags, ShareableSurface::SupportsGraphicsSurface);
+}
+
+static int nextPowerOfTwo(int number)
+{
+ // This is a fast trick to get nextPowerOfTwo for an integer.
+ --number;
+ number |= number >> 1;
+ number |= number >> 2;
+ number |= number >> 4;
+ number |= number >> 8;
+ number |= number >> 16;
+ number++;
+ return number;
+}
+
+void UpdateAtlas::buildLayoutIfNeeded()
+{
+ if (!m_layout.isEmpty())
+ return;
+
+ static const int MinTileSize = 32;
+ static const int MaxTileSize = 512;
+
+ // Divide our square to square power-of-two boxes.
+ for (int cursor = 0; cursor < size().width(); ) {
+ int remainder = size().width() - cursor;
+ int dimension = std::min(remainder, std::min(MaxTileSize, std::max(MinTileSize, nextPowerOfTwo(remainder / 2))));
+ cursor += dimension;
+ m_layout.append(dimension);
+ }
+
+ m_bufferStates.resize(m_layout.size() * m_layout.size());
+ for (int i = 0; i < m_bufferStates.size(); ++i)
+ m_bufferStates[i] = Available;
+}
+
+int UpdateAtlas::findAvailableIndex(const WebCore::IntSize& size)
+{
+ int dimension = m_layout.size();
+ int stride = dimension;
+ int requiredDimension = std::max(size.width(), size.height());
+
+ // Begin from the smallest buffer, until we reach the smallest available buffer that's big enough to contain our rect.
+ for (int i = m_bufferStates.size() - 1; i >= 0; i -= (dimension + 1), --stride) {
+ // Need a bigger buffer.
+ if (m_layout[i / dimension] < requiredDimension)
+ continue;
+
+ // Check all buffers of current size, to find an available one.
+ for (int offset = 0; offset < stride; ++offset) {
+ int index = i - offset;
+ if (m_bufferStates[index] == Available)
+ return index;
+ }
+ }
+
+ return -1;
+}
+
+void UpdateAtlas::didSwapBuffers()
+{
+ buildLayoutIfNeeded();
+ for (int i = 0; i < m_bufferStates.size(); ++i)
+ m_bufferStates[i] = Available;
+}
+
+PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(const WebCore::IntSize& size, IntPoint& offset)
+{
+ buildLayoutIfNeeded();
+ int index = findAvailableIndex(size);
+
+ // No available buffer was found, returning null.
+ if (index < 0)
+ return PassOwnPtr<GraphicsContext>();
+
+ // FIXME: Use tri-state buffers, to allow faster updates.
+ m_bufferStates[index] = Taken;
+ offset = offsetForIndex(index);
+ IntRect rect(IntPoint::zero(), size);
+ OwnPtr<GraphicsContext> graphicsContext = m_surface->createGraphicsContext(IntRect(offset, size));
+
+ if (flags() & ShareableBitmap::SupportsAlpha) {
+ graphicsContext->setCompositeOperation(CompositeCopy);
+ graphicsContext->fillRect(rect, Color::transparent, ColorSpaceDeviceRGB);
+ graphicsContext->setCompositeOperation(CompositeSourceOver);
+ }
+
+ return graphicsContext.release();
+}
+
+IntPoint UpdateAtlas::offsetForIndex(int index) const
+{
+ IntPoint coord(index % m_layout.size(), index / m_layout.size());
+ int x = 0;
+ int y = 0;
+ for (int i = 0; i < coord.x(); ++i)
+ x += m_layout[i];
+ for (int i = 0; i < coord.y(); ++i)
+ y += m_layout[i];
+
+ return IntPoint(x, y);
+}
+
+}
+#endif
diff --git a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h
new file mode 100644
index 000000000..9d10962a3
--- /dev/null
+++ b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h
@@ -0,0 +1,64 @@
+/*
+ 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 library 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 library; 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 UpdateAtlas_h
+#define UpdateAtlas_h
+
+#include "ShareableSurface.h"
+
+#if USE(UI_SIDE_COMPOSITING)
+namespace WebCore {
+class GraphicsContext;
+class IntRect;
+}
+
+namespace WebKit {
+
+class UpdateAtlas {
+public:
+ UpdateAtlas(int dimension, ShareableBitmap::Flags);
+
+ PassRefPtr<ShareableSurface> surface() { return m_surface; }
+ inline WebCore::IntSize size() const { return m_surface->size(); }
+
+ // Returns a null pointer of there is no available buffer.
+ PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer(const WebCore::IntSize&, WebCore::IntPoint& offset);
+ void didSwapBuffers();
+ ShareableBitmap::Flags flags() const { return m_flags; }
+
+private:
+ void buildLayoutIfNeeded();
+ WebCore::IntPoint offsetForIndex(int) const;
+ int findAvailableIndex(const WebCore::IntSize&);
+
+private:
+ enum State {
+ Available,
+ Taken
+ };
+
+ Vector<State> m_bufferStates;
+ Vector<int> m_layout;
+ ShareableBitmap::Flags m_flags;
+ RefPtr<ShareableSurface> m_surface;
+};
+
+}
+#endif
+#endif // UpdateAtlas_h
diff --git a/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp b/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
index cbdc066da..4ca4e5fdb 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
@@ -34,6 +34,7 @@
#include "WebProcess.h"
#include "WebProcessProxyMessages.h"
#include <WebCore/HistoryItem.h>
+#include <WebCore/PageCache.h>
#include <wtf/HashMap.h>
using namespace WebCore;
@@ -128,6 +129,9 @@ void WebBackForwardListProxy::removeItem(uint64_t itemID)
IDToHistoryItemMap::iterator it = idToHistoryItemMap().find(itemID);
if (it == idToHistoryItemMap().end())
return;
+
+ WebCore::pageCache()->remove(it->second.get());
+
historyItemToIDMap().remove(it->second);
idToHistoryItemMap().remove(it);
}
@@ -151,6 +155,8 @@ void WebBackForwardListProxy::addItem(PassRefPtr<HistoryItem> prpItem)
ASSERT(!idToHistoryItemMap().contains(itemID));
+ m_associatedItemIDs.add(itemID);
+
historyItemToIDMap().set(item, itemID);
idToHistoryItemMap().set(itemID, item);
@@ -209,6 +215,12 @@ int WebBackForwardListProxy::forwardListCount()
void WebBackForwardListProxy::close()
{
+ HashSet<uint64_t>::iterator end = m_associatedItemIDs.end();
+ for (HashSet<uint64_t>::iterator i = m_associatedItemIDs.begin(); i != end; ++i)
+ WebCore::pageCache()->remove(itemForID(*i));
+
+ m_associatedItemIDs.clear();
+
m_page = 0;
}
diff --git a/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h b/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
index b69eb123d..84b555198 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
@@ -27,6 +27,7 @@
#define WebBackForwardListProxy_h
#include <WebCore/BackForwardList.h>
+#include <wtf/HashSet.h>
#include <wtf/PassRefPtr.h>
namespace WebKit {
@@ -62,6 +63,7 @@ private:
virtual void close();
WebPage* m_page;
+ HashSet<uint64_t> m_associatedItemIDs;
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
index 8ed674196..3a91d90b7 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp
@@ -20,6 +20,9 @@
*/
#include "config.h"
+
+#if ENABLE(CONTEXT_MENUS)
+
#include "WebContextMenu.h"
#include "InjectedBundleHitTestResult.h"
@@ -93,3 +96,5 @@ void WebContextMenu::itemSelected(const WebContextMenuItemData& item)
}
} // namespace WebKit
+
+#endif // ENABLE(CONTEXT_MENUS)
diff --git a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h
index 3d9291aa3..c8a5f5a46 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h
@@ -21,6 +21,8 @@
#ifndef WebContextMenu_h
#define WebContextMenu_h
+#if ENABLE(CONTEXT_MENUS)
+
#include "WebContextMenuItemData.h"
#include <wtf/PassRefPtr.h>
@@ -50,4 +52,5 @@ private:
} // namespace WebKit
+#endif // ENABLE(CONTEXT_MENUS)
#endif // WebPopupMenu_h
diff --git a/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp b/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
index 417837df6..87573f9ea 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
@@ -50,6 +50,9 @@ WebInspector::WebInspector(WebPage* page)
: m_page(page)
, m_inspectorPage(0)
, m_frontendClient(0)
+#if ENABLE(INSPECTOR_SERVER)
+ , m_remoteFrontendConnected(false)
+#endif
{
}
@@ -99,6 +102,7 @@ void WebInspector::didLoadInspectorPage()
void WebInspector::didClose()
{
WebProcess::shared().connection()->send(Messages::WebInspectorProxy::DidClose(), m_page->pageID());
+ destroyInspectorPage();
}
void WebInspector::bringToFront()
@@ -236,6 +240,36 @@ void WebInspector::updateDockingAvailability()
m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow());
}
+#if ENABLE(INSPECTOR_SERVER)
+void WebInspector::sendMessageToRemoteFrontend(const String& message)
+{
+ ASSERT(m_remoteFrontendConnected);
+ WebProcess::shared().connection()->send(Messages::WebInspectorProxy::SendMessageToRemoteFrontend(message), m_page->pageID());
+}
+
+void WebInspector::dispatchMessageFromRemoteFrontend(const String& message)
+{
+ m_page->corePage()->inspectorController()->dispatchMessageFromFrontend(message);
+}
+
+void WebInspector::remoteFrontendConnected()
+{
+ ASSERT(!m_remoteFrontendConnected);
+ // Switching between in-process and remote inspectors isn't supported yet.
+ ASSERT(!m_inspectorPage);
+
+ m_page->corePage()->inspectorController()->connectFrontend();
+ m_remoteFrontendConnected = true;
+}
+
+void WebInspector::remoteFrontendDisconnected()
+{
+ ASSERT(m_remoteFrontendConnected);
+ m_page->corePage()->inspectorController()->disconnectFrontend();
+ m_remoteFrontendConnected = false;
+}
+#endif
+
} // namespace WebKit
#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/WebProcess/WebPage/WebInspector.h b/Source/WebKit2/WebProcess/WebPage/WebInspector.h
index 1c354f7af..575725ae6 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebInspector.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebInspector.h
@@ -30,8 +30,8 @@
#include "APIObject.h"
#include "Connection.h"
-#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
+#include <wtf/text/WTFString.h>
namespace WebKit {
@@ -61,8 +61,16 @@ public:
void startPageProfiling();
void stopPageProfiling();
+#if ENABLE(INSPECTOR_SERVER)
+ bool hasRemoteFrontendConnected() const { return m_remoteFrontendConnected; }
+ void sendMessageToRemoteFrontend(const String& message);
+ void dispatchMessageFromRemoteFrontend(const String& message);
+ void remoteFrontendConnected();
+ void remoteFrontendDisconnected();
+#endif
+
#if PLATFORM(MAC)
- static void setLocalizedStringsPath(const String&);
+ void setInspectorUsesWebKitUserInterface(bool);
#endif
private:
@@ -108,6 +116,12 @@ private:
WebPage* m_page;
WebPage* m_inspectorPage;
WebInspectorFrontendClient* m_frontendClient;
+#if PLATFORM(MAC)
+ String m_localizedStringsURL;
+#endif
+#if ENABLE(INSPECTOR_SERVER)
+ bool m_remoteFrontendConnected;
+#endif
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in b/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in
index a1a80f07f..998272d9f 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in
+++ b/Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in
@@ -34,6 +34,12 @@ messages -> WebInspector {
StopJavaScriptProfiling()
StartPageProfiling()
StopPageProfiling()
+
+#if ENABLE(INSPECTOR_SERVER)
+ DispatchMessageFromRemoteFrontend(WTF::String message)
+ RemoteFrontendConnected()
+ RemoteFrontendDisconnected()
+#endif
}
#endif
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
index 9f8b417a5..717f67371 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -42,6 +42,7 @@
#include "PrintInfo.h"
#include "SessionState.h"
#include "ShareableBitmap.h"
+#include "WebAlternativeTextClient.h"
#include "WebBackForwardList.h"
#include "WebBackForwardListItem.h"
#include "WebBackForwardListProxy.h"
@@ -97,11 +98,9 @@
#include <WebCore/PlatformKeyboardEvent.h>
#include <WebCore/PluginDocument.h>
#include <WebCore/PrintContext.h>
-#include <WebCore/RenderArena.h>
#include <WebCore/RenderLayer.h>
#include <WebCore/RenderTreeAsText.h>
#include <WebCore/RenderView.h>
-#include <WebCore/ReplaceSelectionCommand.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/RunLoop.h>
#include <WebCore/SchemeRegistry.h>
@@ -129,6 +128,10 @@
#endif
#if PLATFORM(QT)
+#if ENABLE(DEVICE_ORIENTATION)
+#include "DeviceMotionClientQt.h"
+#include "DeviceOrientationClientQt.h"
+#endif
#include "HitTestResult.h"
#include <QMimeData>
#endif
@@ -188,6 +191,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
#if PLATFORM(MAC)
, m_windowIsVisible(false)
, m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled)
+ , m_layerHostingMode(LayerHostingModeDefault)
, m_keyboardEventBeingInterpreted(0)
#elif PLATFORM(WIN)
, m_nativeWindow(parameters.nativeWindow)
@@ -196,9 +200,11 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
#endif
, m_setCanStartMediaTimer(WebProcess::shared().runLoop(), this, &WebPage::setCanStartMediaTimerFired)
, m_findController(this)
+#if ENABLE(TOUCH_EVENTS)
#if PLATFORM(QT)
, m_tapHighlightController(this)
#endif
+#endif
#if ENABLE(GEOLOCATION)
, m_geolocationPermissionRequestManager(this)
#endif
@@ -211,7 +217,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
, m_canShortCircuitHorizontalWheelEvents(false)
, m_numWheelEventHandlers(0)
, m_cachedPageCount(0)
+#if ENABLE(CONTEXT_MENUS)
, m_isShowingContextMenu(false)
+#endif
, m_willGoToBackForwardItemCallbackEnabled(true)
#if PLATFORM(WIN)
, m_gestureReachedScrollingLimit(false)
@@ -224,20 +232,29 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
Page::PageClients pageClients;
pageClients.chromeClient = new WebChromeClient(this);
+#if ENABLE(CONTEXT_MENUS)
pageClients.contextMenuClient = new WebContextMenuClient(this);
+#endif
pageClients.editorClient = new WebEditorClient(this);
pageClients.dragClient = new WebDragClient(this);
pageClients.backForwardClient = WebBackForwardListProxy::create(this);
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
- pageClients.geolocationClient = new WebGeolocationClient(this);
-#endif
#if ENABLE(INSPECTOR)
pageClients.inspectorClient = new WebInspectorClient(this);
#endif
+#if USE(AUTOCORRECTION_PANEL)
+ pageClients.alternativeTextClient = new WebAlternativeTextClient(this);
+#endif
m_page = adoptPtr(new Page(pageClients));
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(GEOLOCATION)
+ WebCore::provideGeolocationTo(m_page.get(), new WebGeolocationClient(this));
+#endif
+#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(QT)
+ WebCore::provideDeviceMotionTo(m_page.get(), new DeviceMotionClientQt);
+ WebCore::provideDeviceOrientationTo(m_page.get(), new DeviceOrientationClientQt);
+#endif
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
WebCore::provideNotification(m_page.get(), new WebNotificationClient(this));
#endif
@@ -253,6 +270,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
m_pageGroup = WebProcess::shared().webPageGroup(parameters.pageGroupData);
m_page->setGroupName(m_pageGroup->identifier());
+ m_page->setDeviceScaleFactor(parameters.deviceScaleFactor);
platformInitialize();
@@ -320,10 +338,12 @@ CoreIPC::Connection* WebPage::connection() const
return WebProcess::shared().connection();
}
+#if ENABLE(CONTEXT_MENUS)
void WebPage::initializeInjectedBundleContextMenuClient(WKBundlePageContextMenuClient* client)
{
m_contextMenuClient.initialize(client);
}
+#endif
void WebPage::initializeInjectedBundleEditorClient(WKBundlePageEditorClient* client)
{
@@ -439,7 +459,7 @@ EditorState WebPage::editorState() const
}
if (selectionRoot)
- result.editorRect = frame->view()->contentsToWindow(selectionRoot->getRect());
+ result.editorRect = frame->view()->contentsToWindow(selectionRoot->getPixelSnappedRect());
RefPtr<Range> range;
if (result.hasComposition && (range = frame->editor()->compositionRange())) {
@@ -482,16 +502,7 @@ uint64_t WebPage::renderTreeSize() const
{
if (!m_page)
return 0;
-
- Frame* mainFrame = m_page->mainFrame();
- if (!mainFrame)
- return 0;
-
- uint64_t size = 0;
- for (Frame* coreFrame = mainFrame; coreFrame; coreFrame = coreFrame->tree()->traverseNext())
- size += coreFrame->document()->renderArena()->totalRenderArenaSize();
-
- return size;
+ return m_page->renderTreeSize().treeSize;
}
void WebPage::setPaintedObjectsCounterThreshold(uint64_t threshold)
@@ -682,6 +693,12 @@ void WebPage::loadPlainTextString(const String& string)
loadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL());
}
+void WebPage::loadWebArchiveData(const CoreIPC::DataReference& webArchiveData)
+{
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(webArchiveData.data()), webArchiveData.size() * sizeof(uint8_t));
+ loadData(sharedBuffer, "application/x-webarchive", "utf-16", blankURL(), KURL());
+}
+
void WebPage::linkClicked(const String& url, const WebMouseEvent& event)
{
Frame* frame = m_page->mainFrame();
@@ -802,9 +819,7 @@ void WebPage::setFixedVisibleContentRect(const IntRect& rect)
{
ASSERT(m_useFixedLayout);
- Frame* frame = m_page->mainFrame();
-
- frame->view()->setFixedVisibleContentRect(rect);
+ m_page->mainFrame()->view()->setFixedVisibleContentRect(rect);
}
void WebPage::setResizesToContentsUsingLayoutSize(const IntSize& targetLayoutSize)
@@ -824,6 +839,9 @@ void WebPage::setResizesToContentsUsingLayoutSize(const IntSize& targetLayoutSiz
// Always reset even when empty.
view->setFixedLayoutSize(targetLayoutSize);
+ m_page->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
+ m_page->settings()->setFixedElementsLayoutRelativeToFrame(true);
+
// Schedule a layout to use the new target size.
if (!view->layoutPending()) {
view->setNeedsLayout();
@@ -840,31 +858,45 @@ void WebPage::resizeToContentsIfNeeded()
if (!view->useFixedLayout())
return;
- IntSize contentSize = view->contentsSize();
- if (contentSize == m_viewSize)
+ IntSize newSize = view->contentsSize().expandedTo(view->fixedLayoutSize());
+
+ if (newSize == m_viewSize)
return;
- m_viewSize = contentSize;
- view->resize(m_viewSize);
+ m_viewSize = newSize;
+ view->resize(newSize);
view->setNeedsLayout();
}
-void WebPage::setViewportSize(const IntSize& size)
+void WebPage::sendViewportAttributesChanged()
{
ASSERT(m_useFixedLayout);
- if (m_viewportSize == size)
+ // Viewport properties have no impact on zero sized fixed viewports.
+ if (m_viewportSize.isEmpty())
return;
- m_viewportSize = size;
-
// Recalculate the recommended layout size, when the available size (device pixel) changes.
Settings* settings = m_page->settings();
- int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), size.width());
+ int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width());
+
+ ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(), static_cast<int>(160 * settings->devicePixelRatio()), m_viewportSize);
+
+ setResizesToContentsUsingLayoutSize(IntSize(static_cast<int>(attr.layoutSize.width()), static_cast<int>(attr.layoutSize.height())));
+ send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
+}
+
+void WebPage::setViewportSize(const IntSize& size)
+{
+ ASSERT(m_useFixedLayout);
+
+ if (m_viewportSize == size)
+ return;
+
+ m_viewportSize = size;
- IntSize targetLayoutSize = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(), settings->deviceDPI(), size).layoutSize;
- setResizesToContentsUsingLayoutSize(targetLayoutSize);
+ sendViewportAttributesChanged();
}
#endif
@@ -1157,9 +1189,6 @@ PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect,
void WebPage::pageDidScroll()
{
- // Hide the find indicator.
- m_findController.hideFindIndicator();
-
m_uiClient.pageDidScroll(this);
send(Messages::WebPageProxy::PageDidScroll());
@@ -1172,12 +1201,14 @@ void WebPage::pageDidRequestScroll(const IntPoint& point)
}
#endif
+#if ENABLE(CONTEXT_MENUS)
WebContextMenu* WebPage::contextMenu()
{
if (!m_contextMenu)
m_contextMenu = WebContextMenu::create(this);
return m_contextMenu.get();
}
+#endif
// Events
@@ -1208,6 +1239,7 @@ private:
const WebEvent* m_previousCurrentEvent;
};
+#if ENABLE(CONTEXT_MENUS)
static bool isContextClick(const PlatformMouseEvent& event)
{
if (event.button() == WebCore::RightButton)
@@ -1237,6 +1269,7 @@ static bool handleContextMenuEvent(const PlatformMouseEvent& platformMouseEvent,
return handled;
}
+#endif
static bool handleMouseEvent(const WebMouseEvent& mouseEvent, WebPage* page, bool onlyUpdateScrollbars)
{
@@ -1248,12 +1281,16 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, WebPage* page, boo
switch (platformMouseEvent.type()) {
case PlatformEvent::MousePressed: {
+#if ENABLE(CONTEXT_MENUS)
if (isContextClick(platformMouseEvent))
page->corePage()->contextMenuController()->clearContextMenu();
-
+#endif
+
bool handled = frame->eventHandler()->handleMousePressEvent(platformMouseEvent);
+#if ENABLE(CONTEXT_MENUS)
if (isContextClick(platformMouseEvent))
handled = handleContextMenuEvent(platformMouseEvent, page);
+#endif
return handled;
}
@@ -1271,11 +1308,13 @@ static bool handleMouseEvent(const WebMouseEvent& mouseEvent, WebPage* page, boo
void WebPage::mouseEvent(const WebMouseEvent& mouseEvent)
{
+#if ENABLE(CONTEXT_MENUS)
// Don't try to handle any pending mouse events if a context menu is showing.
if (m_isShowingContextMenu) {
send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(mouseEvent.type()), false));
return;
}
+#endif
bool handled = false;
@@ -1443,23 +1482,42 @@ void WebPage::restoreSessionAndNavigateToCurrentItem(const SessionState& session
#if ENABLE(TOUCH_EVENTS)
#if PLATFORM(QT)
-void WebPage::highlightPotentialActivation(const IntPoint& point)
+void WebPage::highlightPotentialActivation(const IntPoint& point, const IntSize& area)
{
- Node* activationNode = 0;
- Frame* mainframe = m_page->mainFrame();
+ if (point == IntPoint::zero()) {
+ // An empty point deactivates the highlighting.
+ tapHighlightController().hideHighlight();
+ } else {
+ Frame* mainframe = m_page->mainFrame();
+ Node* activationNode = 0;
+ Node* adjustedNode = 0;
+ IntPoint adjustedPoint;
- if (point != IntPoint::zero()) {
+#if ENABLE(TOUCH_ADJUSTMENT)
+ if (!mainframe->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adjustedPoint, adjustedNode))
+ return;
+
+#else
HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true);
- activationNode = result.innerNode();
+ adjustedNode = result.innerNode();
+#endif
+ // Find the node to highlight. This is not the same as the node responding the tap gesture, because many
+ // pages has a global click handler and we do not want to highlight the body.
+ // Instead find the enclosing link or focusable element, or the last enclosing inline element.
+ for (Node* node = adjustedNode; node; node = node->parentOrHostNode()) {
+ if (node->isMouseFocusable() || node->isLink()) {
+ activationNode = node;
+ break;
+ }
+ if (node->renderer() && node->renderer()->isInline())
+ activationNode = node;
+ else if (activationNode)
+ break;
+ }
- if (!activationNode->isFocusable())
- activationNode = activationNode->enclosingLinkEventParentOrSelf();
+ if (activationNode)
+ tapHighlightController().highlight(activationNode);
}
-
- if (activationNode)
- tapHighlightController().highlight(activationNode);
- else
- tapHighlightController().hideHighlight();
}
#endif
@@ -1857,6 +1915,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
settings->setLoadsSiteIconsIgnoringImageLoadingSetting(store.getBoolValueForKey(WebPreferencesKey::loadsSiteIconsIgnoringImageLoadingPreferenceKey()));
settings->setPluginsEnabled(store.getBoolValueForKey(WebPreferencesKey::pluginsEnabledKey()));
settings->setJavaEnabled(store.getBoolValueForKey(WebPreferencesKey::javaEnabledKey()));
+ settings->setJavaEnabledForLocalFiles(store.getBoolValueForKey(WebPreferencesKey::javaEnabledForLocalFilesKey()));
settings->setOfflineWebApplicationCacheEnabled(store.getBoolValueForKey(WebPreferencesKey::offlineWebApplicationCacheEnabledKey()));
settings->setLocalStorageEnabled(store.getBoolValueForKey(WebPreferencesKey::localStorageEnabledKey()));
settings->setXSSAuditorEnabled(store.getBoolValueForKey(WebPreferencesKey::xssAuditorEnabledKey()));
@@ -1888,7 +1947,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey()));
settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey()));
settings->setLayoutFallbackWidth(store.getUInt32ValueForKey(WebPreferencesKey::layoutFallbackWidthKey()));
- settings->setDeviceDPI(store.getUInt32ValueForKey(WebPreferencesKey::deviceDPIKey()));
+ settings->setDevicePixelRatio(store.getDoubleValueForKey(WebPreferencesKey::devicePixelRatioKey()));
settings->setDeviceWidth(store.getUInt32ValueForKey(WebPreferencesKey::deviceWidthKey()));
settings->setDeviceHeight(store.getUInt32ValueForKey(WebPreferencesKey::deviceHeightKey()));
settings->setEditableLinkBehavior(static_cast<WebCore::EditableLinkBehavior>(store.getUInt32ValueForKey(WebPreferencesKey::editableLinkBehaviorKey())));
@@ -1901,11 +1960,13 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey()));
settings->setCSSCustomFilterEnabled(store.getBoolValueForKey(WebPreferencesKey::cssCustomFilterEnabledKey()));
settings->setCSSRegionsEnabled(store.getBoolValueForKey(WebPreferencesKey::cssRegionsEnabledKey()));
+ settings->setRegionBasedColumnsEnabled(store.getBoolValueForKey(WebPreferencesKey::regionBasedColumnsEnabledKey()));
settings->setWebGLEnabled(store.getBoolValueForKey(WebPreferencesKey::webGLEnabledKey()));
settings->setMediaPlaybackRequiresUserGesture(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackRequiresUserGestureKey()));
settings->setMediaPlaybackAllowsInline(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackAllowsInlineKey()));
settings->setMockScrollbarsEnabled(store.getBoolValueForKey(WebPreferencesKey::mockScrollbarsEnabledKey()));
settings->setHyperlinkAuditingEnabled(store.getBoolValueForKey(WebPreferencesKey::hyperlinkAuditingEnabledKey()));
+ settings->setRequestAnimationFrameEnabled(store.getBoolValueForKey(WebPreferencesKey::requestAnimationFrameEnabledKey()));
// <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.
@@ -1938,9 +1999,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
settings->setWebAudioEnabled(store.getBoolValueForKey(WebPreferencesKey::webAudioEnabledKey()));
#endif
- settings->setApplicationChromeMode(store.getBoolValueForKey(WebPreferencesKey::applicationChromeModeKey()));
+ settings->setApplicationChromeMode(store.getBoolValueForKey(WebPreferencesKey::applicationChromeModeKey()));
settings->setSuppressesIncrementalRendering(store.getBoolValueForKey(WebPreferencesKey::suppressesIncrementalRenderingKey()));
settings->setBackspaceKeyNavigationEnabled(store.getBoolValueForKey(WebPreferencesKey::backspaceKeyNavigationEnabledKey()));
+ settings->setWantsBalancedSetDefersLoadingBehavior(store.getBoolValueForKey(WebPreferencesKey::wantsBalancedSetDefersLoadingBehaviorKey()));
settings->setCaretBrowsingEnabled(store.getBoolValueForKey(WebPreferencesKey::caretBrowsingEnabledKey()));
#if ENABLE(VIDEO_TRACK)
@@ -1949,11 +2011,16 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
settings->setShouldDisplayTextDescriptions(store.getBoolValueForKey(WebPreferencesKey::shouldDisplayTextDescriptionsKey()));
#endif
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
settings->setNotificationsEnabled(store.getBoolValueForKey(WebPreferencesKey::notificationsEnabledKey()));
#endif
+ settings->setShouldRespectImageOrientation(store.getBoolValueForKey(WebPreferencesKey::shouldRespectImageOrientationKey()));
+
platformPreferencesDidChange(store);
+
+ if (m_drawingArea)
+ m_drawingArea->updatePreferences();
}
#if ENABLE(INSPECTOR)
@@ -2093,7 +2160,7 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dra
}
#else
-void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle)
+void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsHandleArray)
{
if (!m_page) {
send(Messages::WebPageProxy::DidPerformDragControllerAction(WebCore::DragSession()));
@@ -2118,6 +2185,8 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli
ASSERT(!m_pendingDropSandboxExtension);
m_pendingDropSandboxExtension = SandboxExtension::create(sandboxExtensionHandle);
+ for (size_t i = 0; i < sandboxExtensionsHandleArray.size(); i++)
+ m_pendingDropExtensionsForFileUpload.append(SandboxExtension::create(sandboxExtensionsHandleArray[i]));
m_page->dragController()->performDrag(&dragData);
@@ -2127,7 +2196,10 @@ void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint cli
m_pendingDropSandboxExtension->invalidate();
m_pendingDropSandboxExtension = nullptr;
}
+ for (size_t i = 0; i < m_pendingDropExtensionsForFileUpload.size(); i++)
+ m_pendingDropExtensionsForFileUpload[i]->invalidate();
+ m_pendingDropExtensionsForFileUpload.clear();
break;
}
@@ -2156,6 +2228,13 @@ void WebPage::willPerformLoadDragDestinationAction()
m_sandboxExtensionTracker.willPerformLoadDragDestinationAction(m_pendingDropSandboxExtension.release());
}
+void WebPage::mayPerformUploadDragDestinationAction()
+{
+ for (size_t i = 0; i < m_pendingDropExtensionsForFileUpload.size(); i++)
+ m_pendingDropExtensionsForFileUpload[i]->consumePermanently();
+ m_pendingDropExtensionsForFileUpload.clear();
+}
+
WebUndoStep* WebPage::webUndoStep(uint64_t stepID)
{
return m_undoStepMap.get(stepID).get();
@@ -2330,6 +2409,7 @@ void WebPage::failedToShowPopupMenu()
}
#endif
+#if ENABLE(CONTEXT_MENUS)
void WebPage::didSelectItemFromActiveContextMenu(const WebContextMenuItemData& item)
{
if (!m_contextMenu)
@@ -2338,6 +2418,7 @@ void WebPage::didSelectItemFromActiveContextMenu(const WebContextMenuItemData& i
m_contextMenu->itemSelected(item);
m_contextMenu = 0;
}
+#endif
void WebPage::replaceSelectionWithText(Frame* frame, const String& text)
{
@@ -2423,17 +2504,21 @@ void WebPage::windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInSc
for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
(*it)->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
}
-
#endif
bool WebPage::windowIsFocused() const
{
+ return m_page->focusController()->isActive();
+}
+
+bool WebPage::windowAndWebPageAreFocused() const
+{
#if PLATFORM(MAC)
if (!m_windowIsVisible)
return false;
#endif
return m_page->focusController()->isFocused() && m_page->focusController()->isActive();
-}
+}
void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
@@ -2482,8 +2567,27 @@ InjectedBundleBackForwardList* WebPage::backForwardList()
}
#if PLATFORM(QT)
-void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point)
+#if ENABLE(TOUCH_ADJUSTMENT)
+void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point, const WebCore::IntSize& area)
{
+ Node* node = 0;
+ IntRect zoomableArea;
+ bool foundAreaForTouchPoint = m_mainFrame->coreFrame()->eventHandler()->bestZoomableAreaForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), zoomableArea, node);
+ ASSERT(node);
+
+ if (!foundAreaForTouchPoint)
+ return;
+
+ if (node->document() && node->document()->view())
+ zoomableArea = node->document()->view()->contentsToWindow(zoomableArea);
+
+ send(Messages::WebPageProxy::DidFindZoomableArea(point, zoomableArea));
+}
+
+#else
+void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point, const WebCore::IntSize& area)
+{
+ UNUSED_PARAM(area);
Frame* mainframe = m_mainFrame->coreFrame();
HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true);
@@ -2519,6 +2623,7 @@ void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point)
send(Messages::WebPageProxy::DidFindZoomableArea(point, zoomableArea));
}
#endif
+#endif
WebPage::SandboxExtensionTracker::~SandboxExtensionTracker()
{
@@ -2614,8 +2719,13 @@ void WebPage::SandboxExtensionTracker::didCommitProvisionalLoad(WebFrame* frame)
{
if (!frame->isMainFrame())
return;
-
- ASSERT(!m_pendingProvisionalSandboxExtension);
+
+ // Generally, there should be no pending extension at this stage, but we can have one if UI process
+ // has an out of date idea of WebProcess state, and initiates a load or reload without stopping an existing one.
+ if (m_pendingProvisionalSandboxExtension) {
+ m_pendingProvisionalSandboxExtension->invalidate();
+ m_pendingProvisionalSandboxExtension = nullptr;
+ }
// The provisional load has been committed. Invalidate the currently committed sandbox
// extension and make the provisional sandbox extension the committed sandbox extension.
@@ -2630,6 +2740,13 @@ void WebPage::SandboxExtensionTracker::didFailProvisionalLoad(WebFrame* frame)
if (!frame->isMainFrame())
return;
+ // Generally, there should be no pending extension at this stage, but we can have one if UI process
+ // has an out of date idea of WebProcess state, and initiates a load or reload without stopping an existing one.
+ if (m_pendingProvisionalSandboxExtension) {
+ m_pendingProvisionalSandboxExtension->invalidate();
+ m_pendingProvisionalSandboxExtension = nullptr;
+ }
+
if (!m_provisionalSandboxExtension)
return;
@@ -2680,8 +2797,8 @@ void WebPage::stopSpeaking()
#endif
-#if USE(CG)
-static RetainPtr<CGPDFDocumentRef> pdfDocumentForPrintingFrame(Frame* coreFrame)
+#if PLATFORM(MAC)
+RetainPtr<PDFDocument> WebPage::pdfDocumentForPrintingFrame(Frame* coreFrame)
{
Document* document = coreFrame->document();
if (!document)
@@ -2696,7 +2813,7 @@ static RetainPtr<CGPDFDocumentRef> pdfDocumentForPrintingFrame(Frame* coreFrame)
return pluginView->pdfDocumentForPrinting();
}
-#endif // USE(CG)
+#endif // PLATFORM(MAC)
void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo)
{
@@ -2708,10 +2825,10 @@ void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo)
if (!coreFrame)
return;
-#if USE(CG)
+#if PLATFORM(MAC)
if (pdfDocumentForPrintingFrame(coreFrame))
return;
-#endif // USE(CG)
+#endif // PLATFORM(MAC)
if (!m_printContext)
m_printContext = adoptPtr(new PrintContext(coreFrame));
@@ -2748,21 +2865,10 @@ void WebPage::computePagesForPrinting(uint64_t frameID, const PrintInfo& printIn
resultPageRects = m_printContext->pageRects();
resultTotalScaleFactorForPrinting = m_printContext->computeAutomaticScaleFactor(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight)) * printInfo.pageSetupScaleFactor;
}
-#if USE(CG)
- else {
- WebFrame* frame = WebProcess::shared().webFrame(frameID);
- Frame* coreFrame = frame ? frame->coreFrame() : 0;
- RetainPtr<CGPDFDocumentRef> pdfDocument = coreFrame ? pdfDocumentForPrintingFrame(coreFrame) : 0;
- if (pdfDocument && CGPDFDocumentAllowsPrinting(pdfDocument.get())) {
- CFIndex pageCount = CGPDFDocumentGetNumberOfPages(pdfDocument.get());
- IntRect pageRect(0, 0, ceilf(printInfo.availablePaperWidth), ceilf(printInfo.availablePaperHeight));
- for (CFIndex i = 1; i <= pageCount; ++i) {
- resultPageRects.append(pageRect);
- pageRect.move(0, pageRect.height());
- }
- }
- }
-#endif // USE(CG)
+#if PLATFORM(MAC)
+ else
+ computePagesForPrintingPDFDocument(frameID, printInfo, resultPageRects);
+#endif // PLATFORM(MAC)
// If we're asked to print, we should actually print at least a blank page.
if (resultPageRects.isEmpty())
@@ -2771,48 +2877,6 @@ void WebPage::computePagesForPrinting(uint64_t frameID, const PrintInfo& printIn
send(Messages::WebPageProxy::ComputedPagesCallback(resultPageRects, resultTotalScaleFactorForPrinting, callbackID));
}
-#if USE(CG)
-static inline CGFloat roundCGFloat(CGFloat f)
-{
- if (sizeof(CGFloat) == sizeof(float))
- return roundf(static_cast<float>(f));
- return static_cast<CGFloat>(round(f));
-}
-
-static void drawPDFPage(CGPDFDocumentRef pdfDocument, CFIndex pageIndex, CGContextRef context, CGFloat pageSetupScaleFactor, CGSize paperSize)
-{
- CGContextSaveGState(context);
-
- CGContextScaleCTM(context, pageSetupScaleFactor, pageSetupScaleFactor);
-
- CGPDFPageRef page = CGPDFDocumentGetPage(pdfDocument, pageIndex + 1);
- CGRect cropBox = CGPDFPageGetBoxRect(page, kCGPDFCropBox);
- if (CGRectIsEmpty(cropBox))
- cropBox = CGRectIntersection(cropBox, CGPDFPageGetBoxRect(page, kCGPDFMediaBox));
- else
- cropBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
-
- bool shouldRotate = (paperSize.width < paperSize.height) != (cropBox.size.width < cropBox.size.height);
- if (shouldRotate)
- swap(cropBox.size.width, cropBox.size.height);
-
- // Center.
- CGFloat widthDifference = paperSize.width / pageSetupScaleFactor - cropBox.size.width;
- CGFloat heightDifference = paperSize.height / pageSetupScaleFactor - cropBox.size.height;
- if (widthDifference || heightDifference)
- CGContextTranslateCTM(context, roundCGFloat(widthDifference / 2), roundCGFloat(heightDifference / 2));
-
- if (shouldRotate) {
- CGContextRotateCTM(context, static_cast<CGFloat>(piOverTwoDouble));
- CGContextTranslateCTM(context, 0, -cropBox.size.width);
- }
-
- CGContextDrawPDFPage(context, page);
-
- CGContextRestoreGState(context);
-}
-#endif // USE(CG)
-
#if PLATFORM(MAC) || PLATFORM(WIN)
void WebPage::drawRectToPDF(uint64_t frameID, const PrintInfo& printInfo, const WebCore::IntRect& rect, uint64_t callbackID)
{
@@ -2822,12 +2886,11 @@ void WebPage::drawRectToPDF(uint64_t frameID, const PrintInfo& printInfo, const
RetainPtr<CFMutableDataRef> pdfPageData(AdoptCF, CFDataCreateMutable(0, 0));
if (coreFrame) {
-#if !USE(CG)
- UNUSED_PARAM(printInfo);
-
- ASSERT(coreFrame->document()->printing());
-#else
+#if PLATFORM(MAC)
ASSERT(coreFrame->document()->printing() || pdfDocumentForPrintingFrame(coreFrame));
+#else
+ ASSERT(coreFrame->document()->printing());
+#endif
// FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data.
RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get()));
@@ -2837,22 +2900,13 @@ void WebPage::drawRectToPDF(uint64_t frameID, const PrintInfo& printInfo, const
RetainPtr<CFDictionaryRef> pageInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CGPDFContextBeginPage(context.get(), pageInfo.get());
- if (RetainPtr<CGPDFDocumentRef> pdfDocument = pdfDocumentForPrintingFrame(coreFrame)) {
- CFIndex pageCount = CGPDFDocumentGetNumberOfPages(pdfDocument.get());
- IntSize paperSize(ceilf(printInfo.availablePaperWidth), ceilf(printInfo.availablePaperHeight));
- IntRect pageRect(IntPoint(), paperSize);
- for (CFIndex i = 0; i < pageCount; ++i) {
- if (pageRect.intersects(rect)) {
- CGContextSaveGState(context.get());
-
- CGContextTranslateCTM(context.get(), pageRect.x() - rect.x(), pageRect.y() - rect.y());
- drawPDFPage(pdfDocument.get(), i, context.get(), printInfo.pageSetupScaleFactor, paperSize);
-
- CGContextRestoreGState(context.get());
- }
- pageRect.move(0, pageRect.height());
- }
- } else {
+#if PLATFORM(MAC)
+ if (RetainPtr<PDFDocument> pdfDocument = pdfDocumentForPrintingFrame(coreFrame)) {
+ ASSERT(!m_printContext);
+ drawRectToPDFFromPDFDocument(context.get(), pdfDocument.get(), printInfo, rect);
+ } else
+#endif
+ {
GraphicsContext ctx(context.get());
ctx.scale(FloatSize(1, -1));
ctx.translate(0, -rect.height());
@@ -2861,7 +2915,6 @@ void WebPage::drawRectToPDF(uint64_t frameID, const PrintInfo& printInfo, const
CGPDFContextEndPage(context.get());
CGPDFContextClose(context.get());
-#endif
}
send(Messages::WebPageProxy::DataCallback(CoreIPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID));
@@ -2876,44 +2929,49 @@ void WebPage::drawPagesToPDF(uint64_t frameID, const PrintInfo& printInfo, uint3
if (coreFrame) {
-#if !USE(CG)
- ASSERT(coreFrame->document()->printing());
-#else
+#if PLATFORM(MAC)
ASSERT(coreFrame->document()->printing() || pdfDocumentForPrintingFrame(coreFrame));
-
- RetainPtr<CGPDFDocumentRef> pdfDocument = pdfDocumentForPrintingFrame(coreFrame);
+#else
+ ASSERT(coreFrame->document()->printing());
+#endif
// FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data.
RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get()));
- CGRect mediaBox = m_printContext && m_printContext->pageCount() ? m_printContext->pageRect(0) : CGRectMake(0, 0, printInfo.availablePaperWidth, printInfo.availablePaperHeight);
+ CGRect mediaBox = (m_printContext && m_printContext->pageCount()) ? m_printContext->pageRect(0) : CGRectMake(0, 0, printInfo.availablePaperWidth, printInfo.availablePaperHeight);
RetainPtr<CGContextRef> context(AdoptCF, CGPDFContextCreate(pdfDataConsumer.get(), &mediaBox, 0));
- size_t pageCount = m_printContext ? m_printContext->pageCount() : CGPDFDocumentGetNumberOfPages(pdfDocument.get());
- for (uint32_t page = first; page < first + count; ++page) {
- if (page >= pageCount)
- break;
- RetainPtr<CFDictionaryRef> pageInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- CGPDFContextBeginPage(context.get(), pageInfo.get());
+#if PLATFORM(MAC)
+ if (RetainPtr<PDFDocument> pdfDocument = pdfDocumentForPrintingFrame(coreFrame)) {
+ ASSERT(!m_printContext);
+ drawPagesToPDFFromPDFDocument(context.get(), pdfDocument.get(), printInfo, first, count);
+ } else
+#endif
+ {
+ size_t pageCount = m_printContext->pageCount();
+ for (uint32_t page = first; page < first + count; ++page) {
+ if (page >= pageCount)
+ break;
+
+ RetainPtr<CFDictionaryRef> pageInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ CGPDFContextBeginPage(context.get(), pageInfo.get());
- if (pdfDocument)
- drawPDFPage(pdfDocument.get(), page, context.get(), printInfo.pageSetupScaleFactor, CGSizeMake(printInfo.availablePaperWidth, printInfo.availablePaperHeight));
- else {
GraphicsContext ctx(context.get());
ctx.scale(FloatSize(1, -1));
ctx.translate(0, -m_printContext->pageRect(page).height());
m_printContext->spoolPage(ctx, page, m_printContext->pageRect(page).width());
- }
- CGPDFContextEndPage(context.get());
+ CGPDFContextEndPage(context.get());
+ }
}
CGPDFContextClose(context.get());
-#endif
}
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);
@@ -2957,12 +3015,12 @@ bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
}
#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
-void WebPage::handleCorrectionPanelResult(const String& result)
+void WebPage::handleAlternativeTextUIResult(const String& result)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
if (!frame)
return;
- frame->editor()->handleCorrectionPanelResult(result);
+ frame->editor()->handleAlternativeTextUIResult(result);
}
#endif
@@ -2987,7 +3045,7 @@ String WebPage::viewportConfigurationAsText(int deviceDPI, int deviceWidth, int
ViewportAttributes attrs = WebCore::computeViewportAttributes(arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight));
WebCore::restrictMinimumScaleFactorToViewportSize(attrs, IntSize(availableWidth, availableHeight));
WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attrs);
- return String::format("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable);
+ return String::format("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", static_cast<int>(attrs.layoutSize.width()), static_cast<int>(attrs.layoutSize.height()), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable);
}
void WebPage::setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length)
@@ -3053,7 +3111,8 @@ static bool pageContainsAnyHorizontalScrollbars(Frame* mainFrame)
for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
ScrollableArea* scrollableArea = *it;
- ASSERT(scrollableArea->isOnActivePage());
+ if (!scrollableArea->isOnActivePage())
+ continue;
if (hasEnabledHorizontalScrollbar(scrollableArea))
return true;
@@ -3093,4 +3152,13 @@ FrameView* WebPage::mainFrameView() const
return 0;
}
+#if ENABLE(PAGE_VISIBILITY_API)
+void WebPage::setVisibilityState(int visibilityState, bool isInitialState)
+{
+ if (!m_page)
+ return;
+ m_page->setVisibilityState(static_cast<WebCore::PageVisibilityState>(visibilityState), isInitialState);
+}
+#endif
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h
index bc84e359c..d9d2df72c 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h
@@ -32,7 +32,9 @@
#include "GeolocationPermissionRequestManager.h"
#include "ImageOptions.h"
#include "ImmutableArray.h"
+#if ENABLE(CONTEXT_MENUS)
#include "InjectedBundlePageContextMenuClient.h"
+#endif
#include "InjectedBundlePageEditorClient.h"
#include "InjectedBundlePageFormClient.h"
#include "InjectedBundlePageFullScreenClient.h"
@@ -81,6 +83,7 @@
#if PLATFORM(MAC)
#include "DictionaryPopupInfo.h"
+#include "LayerHostingContext.h"
#include <wtf/RetainPtr.h>
OBJC_CLASS NSDictionary;
OBJC_CLASS NSObject;
@@ -215,7 +218,9 @@ public:
void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
// -- InjectedBundle methods
+#if ENABLE(CONTEXT_MENUS)
void initializeInjectedBundleContextMenuClient(WKBundlePageContextMenuClient*);
+#endif
void initializeInjectedBundleEditorClient(WKBundlePageEditorClient*);
void initializeInjectedBundleFormClient(WKBundlePageFormClient*);
void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient*);
@@ -226,7 +231,9 @@ public:
void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient*);
#endif
+#if ENABLE(CONTEXT_MENUS)
InjectedBundlePageContextMenuClient& injectedBundleContextMenuClient() { return m_contextMenuClient; }
+#endif
InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
InjectedBundlePageFormClient& injectedBundleFormClient() { return m_formClient; }
InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
@@ -299,7 +306,11 @@ public:
void addPluginView(PluginView*);
void removePluginView(PluginView*);
+ LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
+ void setLayerHostingMode(LayerHostingMode);
+
bool windowIsVisible() const { return m_windowIsVisible; }
+ void updatePluginsActiveAndFocusedState();
const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
#elif PLATFORM(WIN)
@@ -307,6 +318,7 @@ public:
#endif
bool windowIsFocused() const;
+ bool windowAndWebPageAreFocused() const;
void installPageOverlay(PassRefPtr<PageOverlay>);
void uninstallPageOverlay(PageOverlay*, bool fadeOut);
bool hasPageOverlay() const { return m_pageOverlay; }
@@ -320,7 +332,7 @@ public:
static const WebEvent* currentEvent();
FindController& findController() { return m_findController; }
-#if PLATFORM(QT)
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
TapHighlightController& tapHighlightController() { return m_tapHighlightController; }
#endif
@@ -336,11 +348,14 @@ public:
void setFixedVisibleContentRect(const WebCore::IntRect&);
void setResizesToContentsUsingLayoutSize(const WebCore::IntSize&);
void resizeToContentsIfNeeded();
+ void sendViewportAttributesChanged();
void setViewportSize(const WebCore::IntSize&);
WebCore::IntSize viewportSize() const { return m_viewportSize; }
#endif
+#if ENABLE(CONTEXT_MENUS)
WebContextMenu* contextMenu();
+#endif
bool hasLocalDataForURL(const WebCore::KURL&);
String cachedResponseMIMETypeForURL(const WebCore::KURL&);
@@ -394,8 +409,9 @@ public:
void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
- void writeSelectionToPasteboard(const WTF::String& pasteboardName, const WTF::Vector<WTF::String>& pasteboardTypes, bool& result);
void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
+ void getStringSelectionForPasteboard(WTF::String& stringValue);
+ void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
bool performNonEditingBehaviorForSelector(const String&);
@@ -439,11 +455,12 @@ public:
#elif PLATFORM(QT) || PLATFORM(GTK)
void performDragControllerAction(uint64_t action, WebCore::DragData);
#else
- void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&);
+ void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
#endif
void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
void willPerformLoadDragDestinationAction();
+ void mayPerformUploadDragDestinationAction();
void beginPrinting(uint64_t frameID, const PrintInfo&);
void endPrinting();
@@ -482,7 +499,7 @@ public:
void unmarkAllBadGrammar();
#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
- void handleCorrectionPanelResult(const String&);
+ void handleAlternativeTextUIResult(const String&);
#endif
// For testing purpose.
@@ -491,7 +508,9 @@ public:
void simulateMouseMotion(WebCore::IntPoint, double time);
String viewportConfigurationAsText(int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
+#if ENABLE(CONTEXT_MENUS)
void contextMenuShowing() { m_isShowingContextMenu = true; }
+#endif
#if PLATFORM(QT)
void registerApplicationScheme(const String& scheme);
@@ -507,7 +526,11 @@ public:
void recomputeShortCircuitHorizontalWheelEventsState();
bool willGoToBackForwardItemCallbackEnabled() const { return m_willGoToBackForwardItemCallbackEnabled; }
-
+
+#if ENABLE(PAGE_VISIBILITY_API)
+ void setVisibilityState(int visibilityState, bool isInitialState);
+#endif
+
private:
WebPage(uint64_t pageID, const WebPageCreationParameters&);
@@ -540,6 +563,7 @@ private:
void loadHTMLString(const String& htmlString, const String& baseURL);
void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL);
void loadPlainTextString(const String&);
+ void loadWebArchiveData(const CoreIPC::DataReference&);
void linkClicked(const String& url, const WebMouseEvent&);
void reload(bool reloadFromOrigin, const SandboxExtension::Handle&);
void goForward(uint64_t);
@@ -563,10 +587,12 @@ private:
void touchEvent(const WebTouchEvent&);
void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
#if PLATFORM(QT)
- void highlightPotentialActivation(const WebCore::IntPoint&);
+ void highlightPotentialActivation(const WebCore::IntPoint&, const WebCore::IntSize& area);
#endif
#endif
+#if ENABLE(CONTEXT_MENUS)
void contextMenuHidden() { m_isShowingContextMenu = false; }
+#endif
static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
@@ -610,6 +636,11 @@ private:
void setWindowIsVisible(bool windowIsVisible);
void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
+
+ RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
+ void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
+ void drawRectToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
+ void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
#endif
void unapplyEditCommand(uint64_t commandID);
@@ -621,7 +652,7 @@ private:
void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
#if PLATFORM(QT)
- void findZoomableAreaForPoint(const WebCore::IntPoint&);
+ void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
#endif
void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
@@ -698,6 +729,9 @@ private:
// All plug-in views on this web page.
HashSet<PluginView*> m_pluginViews;
+ // The layer hosting mode.
+ LayerHostingMode m_layerHostingMode;
+
RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted;
@@ -717,7 +751,9 @@ private:
WebCore::IntSize m_windowResizerSize;
+#if ENABLE(CONTEXT_MENUS)
InjectedBundlePageContextMenuClient m_contextMenuClient;
+#endif
InjectedBundlePageEditorClient m_editorClient;
InjectedBundlePageFormClient m_formClient;
InjectedBundlePageLoaderClient m_loaderClient;
@@ -733,7 +769,7 @@ private:
#endif
FindController m_findController;
-#if PLATFORM(QT)
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
TapHighlightController m_tapHighlightController;
#endif
RefPtr<PageOverlay> m_pageOverlay;
@@ -747,7 +783,9 @@ private:
RefPtr<WebFullScreenManager> m_fullScreenManager;
#endif
RefPtr<WebPopupMenu> m_activePopupMenu;
+#if ENABLE(CONTEXT_MENUS)
RefPtr<WebContextMenu> m_contextMenu;
+#endif
RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
@@ -764,6 +802,7 @@ private:
uint64_t m_pageID;
RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
+ Vector<RefPtr<SandboxExtension> > m_pendingDropExtensionsForFileUpload;
bool m_canRunBeforeUnloadConfirmPanel;
@@ -777,7 +816,9 @@ private:
unsigned m_cachedPageCount;
+#if ENABLE(CONTEXT_MENUS)
bool m_isShowingContextMenu;
+#endif
bool m_willGoToBackForwardItemCallbackEnabled;
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
index 2c9436042..8381f2603 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -40,12 +40,13 @@ messages -> WebPage {
#if ENABLE(TOUCH_EVENTS)
TouchEvent(WebKit::WebTouchEvent event)
TouchEventSyncForTesting(WebKit::WebTouchEvent event) -> (bool handled)
-#if PLATFORM(QT)
- HighlightPotentialActivation(WebCore::IntPoint point)
-#endif
+#if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
+ HighlightPotentialActivation(WebCore::IntPoint point, WebCore::IntSize area)
#endif
+#if ENABLE(CONTEXT_MENUS)
ContextMenuHidden()
+#endif
ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
CenterSelectionInVisibleArea()
@@ -57,6 +58,7 @@ messages -> WebPage {
LoadHTMLString(WTF::String htmlString, WTF::String baseURL)
LoadAlternateHTMLString(WTF::String htmlString, WTF::String baseURL, WTF::String unreachableURL);
LoadPlainTextString(WTF::String string)
+ LoadWebArchiveData(CoreIPC::DataReference webArchiveData)
LoadURL(WTF::String url, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
LoadURLRequest(WebCore::ResourceRequest request, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
LinkClicked(WTF::String url, WebKit::WebMouseEvent event)
@@ -105,7 +107,6 @@ messages -> WebPage {
ResumeActiveDOMObjectsAndAnimations()
#if USE(TILED_BACKING_STORE)
- SetFixedVisibleContentRect(WebCore::IntRect rect)
SetViewportSize(WebCore::IntSize size)
#endif
@@ -147,7 +148,7 @@ messages -> WebPage {
PerformDragControllerAction(uint64_t action, WebCore::DragData dragData)
#endif
#if !PLATFORM(WIN) && !PLATFORM(QT) && !PLATFORM(GTK)
- PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
+ PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::SandboxExtension::HandleArray sandboxExtensionsForUpload)
#endif
DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation)
@@ -158,8 +159,10 @@ messages -> WebPage {
FailedToShowPopupMenu();
#endif
+#if ENABLE(CONTEXT_MENUS)
# Context menu.
DidSelectItemFromActiveContextMenu(WebKit::WebContextMenuItemData menuItem);
+#endif
# Open panel.
DidChooseFilesForOpenPanel(Vector<WTF::String> fileURLs)
@@ -226,7 +229,8 @@ messages -> WebPage {
SetWindowIsVisible(bool windowIsVisible)
WindowAndViewFramesChanged(WebCore::IntRect windowFrameInScreenCoordinates, WebCore::IntRect viewFrameInWindowCoordinates, WebCore::IntPoint accessibilityViewCoordinates)
RegisterUIProcessAccessibilityTokens(CoreIPC::DataReference elemenToken, CoreIPC::DataReference windowToken)
- WriteSelectionToPasteboard(WTF::String pasteboardName, WTF::Vector<WTF::String> pasteboardTypes) -> (bool result)
+ GetStringSelectionForPasteboard() -> (WTF::String stringValue)
+ GetDataSelectionForPasteboard(WTF::String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size)
ReadSelectionFromPasteboard(WTF::String pasteboardName) -> (bool result)
# Text input.
@@ -255,10 +259,14 @@ messages -> WebPage {
GestureDidEnd()
#endif
#if PLATFORM(QT)
- FindZoomableAreaForPoint(WebCore::IntPoint point)
+ FindZoomableAreaForPoint(WebCore::IntPoint point, WebCore::IntSize area)
#endif
#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
- HandleCorrectionPanelResult(String result)
+ HandleAlternativeTextUIResult(String result)
+#endif
+
+#if ENABLE(PAGE_VISIBILITY_API)
+ SetVisibilityState(int visibilityState, bool isInitialState);
#endif
}
diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h
index 8f41355c3..375f8c6d6 100644
--- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h
+++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h
@@ -51,6 +51,8 @@ private:
virtual void pauseRendering();
virtual void resumeRendering();
+ virtual void setLayerHostingMode(LayerHostingMode) OVERRIDE;
+
// LayerTreeHostCA
virtual void platformInitialize(LayerTreeContext&);
virtual void didPerformScheduledLayerFlush();
diff --git a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm
index e72bd2293..aeca22445 100644
--- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm
+++ b/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm
@@ -27,6 +27,7 @@
#import "LayerTreeHostCAMac.h"
#import "LayerHostingContext.h"
+#import "WebPage.h"
#import "WebProcess.h"
#import <QuartzCore/CATransaction.h>
#import <WebCore/GraphicsLayer.h>
@@ -59,7 +60,16 @@ LayerTreeHostCAMac::~LayerTreeHostCAMac()
void LayerTreeHostCAMac::platformInitialize(LayerTreeContext& layerTreeContext)
{
- m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+ switch (m_webPage->layerHostingMode()) {
+ case LayerHostingModeDefault:
+ m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+ break;
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+ case LayerHostingModeInWindowServer:
+ m_layerHostingContext = LayerHostingContext::createForWindowServer();
+ break;
+#endif
+ }
m_layerHostingContext->setRootLayer(rootLayer()->platformLayer());
layerTreeContext.contextID = m_layerHostingContext->contextID();
@@ -118,11 +128,7 @@ void LayerTreeHostCAMac::resumeRendering()
bool LayerTreeHostCAMac::flushLayers()
{
- // This gets called outside of the normal event loop so wrap in an autorelease pool
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
performScheduledLayerFlush();
- [pool drain];
-
return true;
}
@@ -139,4 +145,32 @@ bool LayerTreeHostCAMac::flushPendingLayerChanges()
return LayerTreeHostCA::flushPendingLayerChanges();
}
+void LayerTreeHostCAMac::setLayerHostingMode(LayerHostingMode layerHostingMode)
+{
+ if (layerHostingMode == m_layerHostingContext->layerHostingMode())
+ return;
+
+ // The mode has changed.
+
+ // First, invalidate the old hosting context.
+ m_layerHostingContext->invalidate();
+ m_layerHostingContext = nullptr;
+
+ // Create a new context and set it up.
+ switch (layerHostingMode) {
+ case LayerHostingModeDefault:
+ m_layerHostingContext = LayerHostingContext::createForPort(WebProcess::shared().compositingRenderServerPort());
+ break;
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+ case LayerHostingModeInWindowServer:
+ m_layerHostingContext = LayerHostingContext::createForWindowServer();
+ break;
+#endif
+ }
+
+ m_layerHostingContext->setRootLayer(rootLayer()->platformLayer());
+
+ scheduleLayerFlush();
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
index b0440cf33..095f77312 100644
--- a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
@@ -26,8 +26,10 @@
#include "config.h"
#include "WebPrintOperationGtk.h"
+#include "WebCoreArgumentCoders.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
+#include <WebCore/ErrorsGtk.h>
#include <WebCore/IntRect.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/PlatformContextCairo.h>
@@ -72,13 +74,14 @@ public:
static void enumeratePrintersFinished(WebPrintOperationGtkUnix* printOperation)
{
if (!printOperation->m_printJob) {
- // FIXME: Printing error.
+ printOperation->printDone(printerNotFoundError(printOperation->m_printContext));
return;
}
- cairo_surface_t* surface = gtk_print_job_get_surface(printOperation->m_printJob.get(), 0);
+ GOwnPtr<GError> error;
+ cairo_surface_t* surface = gtk_print_job_get_surface(printOperation->m_printJob.get(), &error.outPtr());
if (!surface) {
- // FIXME: Printing error.
+ printOperation->printDone(printError(printOperation->m_printContext, error->message));
return;
}
@@ -143,8 +146,9 @@ public:
cairo_show_page(cr);
}
- static void printJobComplete(GtkPrintJob* printJob, WebPrintOperationGtkUnix* printOperation, const GError*)
+ static void printJobComplete(GtkPrintJob* printJob, WebPrintOperationGtkUnix* printOperation, const GError* error)
{
+ printOperation->printDone(error ? printError(printOperation->m_printContext, error->message) : WebCore::ResourceError());
printOperation->m_printJob = 0;
}
@@ -210,6 +214,7 @@ struct PrintPagesData {
, collated(0)
, uncollated(0)
, isDone(false)
+ , isValid(true)
{
if (printOperation->collateCopies()) {
collatedCopies = printOperation->copies();
@@ -247,6 +252,11 @@ struct PrintPagesData {
for (int i = 0; i < printOperation->pageCount(); ++i)
pages.append(i);
}
+
+ if (!pages.size()) {
+ isValid = false;
+ return;
+ }
printOperation->setNumberOfPagesToPrint(pages.size());
size_t numberUp = printOperation->numberUp();
@@ -282,9 +292,11 @@ struct PrintPagesData {
break;
}
- // FIXME: check pagePostion is between [0..pages.size() - 1]
- // and cancel the operation otherwise when error reporting
- // is implemented.
+ if (sheetNumber * numberUp >= pages.size()) {
+ isValid = false;
+ return;
+ }
+
printOperation->setPagePosition(sheetNumber * numberUp);
pageNumber = pages[printOperation->pagePosition()];
firstPagePosition = printOperation->pagePosition();
@@ -361,6 +373,7 @@ struct PrintPagesData {
size_t uncollatedCopies;
bool isDone : 1;
+ bool isValid : 1;
};
PassRefPtr<WebPrintOperationGtk> WebPrintOperationGtk::create(WebPage* page, const PrintInfo& printInfo)
@@ -656,31 +669,42 @@ void WebPrintOperationGtk::printPagesIdleDone(gpointer userData)
{
PrintPagesData* data = static_cast<PrintPagesData*>(userData);
- data->printOperation->printDone();
+ data->printOperation->printPagesDone();
delete data;
}
-void WebPrintOperationGtk::printDone()
+void WebPrintOperationGtk::printPagesDone()
{
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::printDone(const WebCore::ResourceError& error)
+{
+ if (m_printPagesIdleId)
+ g_source_remove(m_printPagesIdleId);
+ m_printPagesIdleId = 0;
+
+ // Print finished or failed, notify the UI process that we are done.
+ m_webPage->send(Messages::WebPageProxy::PrintFinishedCallback(error, m_callbackID));
+}
+
void WebPrintOperationGtk::print(cairo_surface_t* surface, double xDPI, double yDPI)
{
ASSERT(m_printContext);
+ OwnPtr<PrintPagesData> data = adoptPtr(new PrintPagesData(this));
+ if (!data->isValid) {
+ printDone(invalidPageRangeToPrint(m_printContext));
+ return;
+ }
+
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);
+ data.leakPtr(), printPagesIdleDone);
}
}
diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h
index 5821a2ed3..3d1f1086d 100644
--- a/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h
+++ b/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h
@@ -38,6 +38,7 @@ typedef struct _GtkPageRange GtkPageRange;
namespace WebCore {
class PrintContext;
+class ResourceError;
};
namespace WebKit {
@@ -49,6 +50,7 @@ public:
static PassRefPtr<WebPrintOperationGtk> create(WebPage*, const PrintInfo&);
~WebPrintOperationGtk();
+ WebCore::PrintContext* printContext() const { return m_printContext; }
GtkPrintSettings* printSettings() const { return m_printSettings.get(); }
GtkPageSetup* pageSetup() const { return m_pageSetup.get(); }
void setNumberOfPagesToPrint(size_t numberOfPages) { m_numberOfPagesToPrint = numberOfPages; }
@@ -87,7 +89,8 @@ protected:
void getRowsAndColumnsOfPagesPerSheet(size_t& rows, size_t& columns);
void getPositionOfPageInSheet(size_t rows, size_t columns, int& x, int&y);
void prepareContextToDraw();
- void printDone();
+ void printPagesDone();
+ void printDone(const WebCore::ResourceError&);
WebPage* m_webPage;
GRefPtr<GtkPrintSettings> m_printSettings;
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
index a86413f2f..8608f0755 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
+++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
@@ -26,6 +26,8 @@
#ifndef TiledCoreAnimationDrawingArea_h
#define TiledCoreAnimationDrawingArea_h
+#if ENABLE(THREADED_SCROLLING)
+
#include "DrawingArea.h"
#include "LayerTreeContext.h"
#include <WebCore/GraphicsLayerClient.h>
@@ -62,6 +64,9 @@ private:
virtual void didInstallPageOverlay() OVERRIDE;
virtual void didUninstallPageOverlay() OVERRIDE;
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) OVERRIDE;
+ virtual void updatePreferences() OVERRIDE;
+
+ virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&) OVERRIDE;
// WebCore::GraphicsLayerClient
virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) OVERRIDE;
@@ -75,6 +80,8 @@ private:
virtual bool flushLayers() OVERRIDE;
// Message handlers.
+ virtual void suspendPainting() OVERRIDE;
+ virtual void resumePainting() OVERRIDE;
virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
virtual void setDeviceScaleFactor(float) OVERRIDE;
virtual void setLayerHostingMode(uint32_t) OVERRIDE;
@@ -84,8 +91,6 @@ private:
void createPageOverlayLayer();
void destroyPageOverlayLayer();
- bool shouldRepaintPageOverlayLayer();
-
bool m_layerTreeStateIsFrozen;
WebCore::LayerFlushScheduler m_layerFlushScheduler;
@@ -95,10 +100,15 @@ private:
RetainPtr<CALayer> m_rootLayer;
RetainPtr<CALayer> m_pendingRootCompositingLayer;
+ RetainPtr<CALayer> m_debugInfoLayer;
+
OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
- WebCore::FloatPoint m_mainFrameScrollLayerPosition;
+
+ bool m_isPaintingSuspended;
};
} // namespace WebKit
+#endif // ENABLE(THREADED_SCROLLING)
+
#endif // TiledCoreAnimationDrawingArea_h
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
index ddb4902b9..9a7ccdf64 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
@@ -26,11 +26,14 @@
#import "config.h"
#import "TiledCoreAnimationDrawingArea.h"
+#if ENABLE(THREADED_SCROLLING)
+
#import "DrawingAreaProxyMessages.h"
#import "EventDispatcher.h"
#import "LayerHostingContext.h"
#import "LayerTreeContext.h"
#import "WebPage.h"
+#import "WebPageCreationParameters.h"
#import "WebPageProxyMessages.h"
#import "WebProcess.h"
#import <QuartzCore/QuartzCore.h>
@@ -42,6 +45,7 @@
#import <WebCore/RenderView.h>
#import <WebCore/ScrollingCoordinator.h>
#import <WebCore/ScrollingThread.h>
+#import <WebCore/ScrollingTree.h>
#import <WebCore/Settings.h>
#import <wtf/MainThread.h>
@@ -62,17 +66,15 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c
: DrawingArea(DrawingAreaTypeTiledCoreAnimation, webPage)
, m_layerTreeStateIsFrozen(false)
, m_layerFlushScheduler(this)
+ , m_isPaintingSuspended(!parameters.isVisible)
{
Page* page = webPage->corePage();
// FIXME: It's weird that we're mucking around with the settings here.
page->settings()->setForceCompositingMode(true);
-
-#if ENABLE(THREADED_SCROLLING)
page->settings()->setScrollingCoordinatorEnabled(true);
WebProcess::shared().eventDispatcher().addScrollingTreeForPage(webPage);
-#endif
m_rootLayer = [CALayer layer];
@@ -87,13 +89,13 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c
LayerTreeContext layerTreeContext;
layerTreeContext.contextID = m_layerHostingContext->contextID();
m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(0, layerTreeContext));
+
+ updatePreferences();
}
TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()
{
-#if ENABLE(THREADED_SCROLLING)
WebProcess::shared().eventDispatcher().removeScrollingTreeForPage(m_webPage);
-#endif
m_layerFlushScheduler.invalidate();
}
@@ -110,6 +112,13 @@ void TiledCoreAnimationDrawingArea::setRootCompositingLayer(GraphicsLayer* graph
{
CALayer *rootCompositingLayer = graphicsLayer ? graphicsLayer->platformLayer() : nil;
+ // Since we'll always be in accelerated compositing mode, the only time that layer will be nil
+ // is when the WKView is removed from its containing window. In that case, the layer will already be
+ // removed from the layer tree hierarchy over in the UI process, so there's no reason to remove it locally.
+ // In addition, removing the layer here will cause flashes when switching between tabs.
+ if (!rootCompositingLayer)
+ return;
+
if (m_layerTreeStateIsFrozen) {
m_pendingRootCompositingLayer = rootCompositingLayer;
return;
@@ -128,34 +137,16 @@ void TiledCoreAnimationDrawingArea::forceRepaint()
[CATransaction synchronize];
}
-#if ENABLE(THREADED_SCROLLING)
-static void forceRepaintAndSendMessage(uint64_t webPageID, uint64_t callbackID)
-{
- WebPage* webPage = WebProcess::shared().webPage(webPageID);
- if (!webPage)
- return;
-
- webPage->drawingArea()->forceRepaint();
- webPage->send(Messages::WebPageProxy::VoidCallback(callbackID));
-}
-
-static void dispatchBackToMainThread(uint64_t webPageID, uint64_t callbackID)
-{
- callOnMainThread(bind(forceRepaintAndSendMessage, webPageID, callbackID));
-}
-#endif
-
bool TiledCoreAnimationDrawingArea::forceRepaintAsync(uint64_t callbackID)
{
-#if ENABLE(THREADED_SCROLLING)
if (m_layerTreeStateIsFrozen)
return false;
- ScrollingThread::dispatch(bind(dispatchBackToMainThread, m_webPage->pageID(), callbackID));
+ dispatchAfterEnsuringUpdatedScrollPosition(bind(^{
+ m_webPage->drawingArea()->forceRepaint();
+ m_webPage->send(Messages::WebPageProxy::VoidCallback(callbackID));
+ }));
return true;
-#else
- return false;
-#endif
}
void TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen(bool layerTreeStateIsFrozen)
@@ -182,9 +173,7 @@ void TiledCoreAnimationDrawingArea::scheduleCompositingLayerSync()
void TiledCoreAnimationDrawingArea::didInstallPageOverlay()
{
-#if ENABLE(THREADED_SCROLLING)
m_webPage->corePage()->scrollingCoordinator()->setForceMainThreadScrollLayerPositionUpdates(true);
-#endif
createPageOverlayLayer();
scheduleCompositingLayerSync();
@@ -192,9 +181,8 @@ void TiledCoreAnimationDrawingArea::didInstallPageOverlay()
void TiledCoreAnimationDrawingArea::didUninstallPageOverlay()
{
-#if ENABLE(THREADED_SCROLLING)
- m_webPage->corePage()->scrollingCoordinator()->setForceMainThreadScrollLayerPositionUpdates(false);
-#endif
+ if (Page* page = m_webPage->corePage())
+ page->scrollingCoordinator()->setForceMainThreadScrollLayerPositionUpdates(false);
destroyPageOverlayLayer();
scheduleCompositingLayerSync();
@@ -207,6 +195,43 @@ void TiledCoreAnimationDrawingArea::setPageOverlayNeedsDisplay(const IntRect& re
scheduleCompositingLayerSync();
}
+void TiledCoreAnimationDrawingArea::updatePreferences()
+{
+ bool showDebugBorders = m_webPage->corePage()->settings()->showDebugBorders();
+
+ if (showDebugBorders == !!m_debugInfoLayer)
+ return;
+
+ if (showDebugBorders) {
+ m_debugInfoLayer = [CALayer layer];
+ [m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];
+ } else {
+ [m_debugInfoLayer.get() removeFromSuperlayer];
+ m_debugInfoLayer = nullptr;
+ }
+
+ ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer));
+}
+
+void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& functionRef)
+{
+ m_webPage->ref();
+ m_webPage->corePage()->scrollingCoordinator()->commitTreeStateIfNeeded();
+
+ if (!m_layerTreeStateIsFrozen)
+ m_layerFlushScheduler.suspend();
+
+ Function<void ()> function = functionRef;
+ ScrollingThread::dispatchBarrier(bind(^{
+ function();
+
+ if (!m_layerTreeStateIsFrozen)
+ m_layerFlushScheduler.resume();
+
+ m_webPage->deref();
+ }));
+}
+
void TiledCoreAnimationDrawingArea::notifyAnimationStarted(const GraphicsLayer*, double)
{
}
@@ -252,9 +277,7 @@ bool TiledCoreAnimationDrawingArea::flushLayers()
}
if (m_pageOverlayLayer) {
- if (shouldRepaintPageOverlayLayer())
- m_pageOverlayLayer->setNeedsDisplay();
-
+ m_pageOverlayLayer->setNeedsDisplay();
m_pageOverlayLayer->syncCompositingStateForThisLayerOnly();
}
@@ -264,6 +287,33 @@ bool TiledCoreAnimationDrawingArea::flushLayers()
return returnValue;
}
+void TiledCoreAnimationDrawingArea::suspendPainting()
+{
+ ASSERT(!m_isPaintingSuspended);
+ m_isPaintingSuspended = true;
+
+ [m_rootLayer.get() setValue:(id)kCFBooleanTrue forKey:@"NSCAViewRenderPaused"];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidPauseNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:m_rootLayer.get() forKey:@"layer"]];
+
+ m_webPage->corePage()->suspendScriptedAnimations();
+}
+
+void TiledCoreAnimationDrawingArea::resumePainting()
+{
+ if (!m_isPaintingSuspended) {
+ // FIXME: We can get a call to resumePainting when painting is not suspended.
+ // This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
+ return;
+ }
+ m_isPaintingSuspended = false;
+
+ [m_rootLayer.get() setValue:(id)kCFBooleanFalse forKey:@"NSCAViewRenderPaused"];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:m_rootLayer.get() forKey:@"layer"]];
+
+ if (m_webPage->windowIsVisible())
+ m_webPage->corePage()->resumeScriptedAnimations();
+}
+
void TiledCoreAnimationDrawingArea::updateGeometry(const IntSize& viewSize)
{
m_webPage->setSize(viewSize);
@@ -317,6 +367,8 @@ void TiledCoreAnimationDrawingArea::setLayerHostingMode(uint32_t opaqueLayerHost
m_layerHostingContext->setRootLayer(m_rootLayer.get());
+ m_webPage->setLayerHostingMode(layerHostingMode);
+
// Finally, inform the UIProcess that the context has changed.
LayerTreeContext layerTreeContext;
layerTreeContext.contextID = m_layerHostingContext->contextID();
@@ -326,19 +378,19 @@ void TiledCoreAnimationDrawingArea::setLayerHostingMode(uint32_t opaqueLayerHost
void TiledCoreAnimationDrawingArea::setRootCompositingLayer(CALayer *layer)
{
+ ASSERT(layer);
ASSERT(!m_layerTreeStateIsFrozen);
[CATransaction begin];
[CATransaction setDisableActions:YES];
- if (!layer)
- m_rootLayer.get().sublayers = nil;
- else {
- m_rootLayer.get().sublayers = [NSArray arrayWithObject:layer];
+ m_rootLayer.get().sublayers = [NSArray arrayWithObject:layer];
- if (m_pageOverlayLayer)
- [m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
- }
+ if (m_pageOverlayLayer)
+ [m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
+
+ if (m_debugInfoLayer)
+ [m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];
[CATransaction commit];
}
@@ -352,10 +404,16 @@ void TiledCoreAnimationDrawingArea::createPageOverlayLayer()
m_pageOverlayLayer->setName("page overlay content");
#endif
+ m_pageOverlayLayer->setAcceleratesDrawing(true);
m_pageOverlayLayer->setDrawsContent(true);
m_pageOverlayLayer->setSize(m_webPage->size());
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+
[m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
+
+ [CATransaction commit];
}
void TiledCoreAnimationDrawingArea::destroyPageOverlayLayer()
@@ -366,20 +424,6 @@ void TiledCoreAnimationDrawingArea::destroyPageOverlayLayer()
m_pageOverlayLayer = nullptr;
}
-bool TiledCoreAnimationDrawingArea::shouldRepaintPageOverlayLayer()
-{
- RenderLayerCompositor* renderLayerCompositor = m_webPage->corePage()->mainFrame()->contentRenderer()->compositor();
- GraphicsLayer* scrollLayer = renderLayerCompositor->scrollLayer();
- if (m_mainFrameScrollLayerPosition != scrollLayer->position()) {
- m_mainFrameScrollLayerPosition = scrollLayer->position();
- return true;
- }
-
- GraphicsLayer* rootGraphicsLayer = renderLayerCompositor->rootRenderLayer()->backing()->graphicsLayer();
- if (rootGraphicsLayer->needsDisplay())
- return true;
-
- return false;
-}
-
} // namespace WebKit
+
+#endif // ENABLE(THREADED_SCROLLING)
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm b/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm
index 6ed37ea10..c7229a9be 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm
@@ -43,6 +43,9 @@ using namespace WebKit;
- (id)accessibilityRootObjectWrapper
{
+ if (!WebCore::AXObjectCache::accessibilityEnabled())
+ WebCore::AXObjectCache::enableAccessibility();
+
WebCore::Page* page = m_page->corePage();
if (!page)
return nil;
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm
index d64bf9cf5..1fa87957b 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorMac.mm
@@ -26,27 +26,41 @@
#import "config.h"
#import "WebInspector.h"
-#import <wtf/text/WTFString.h>
+#import <WebCore/SoftLinking.h>
+
+SOFT_LINK_STAGED_FRAMEWORK_OPTIONAL(WebInspector, PrivateFrameworks)
namespace WebKit {
-static String& globalInspectorLocalizedStringsURL()
+static bool inspectorReallyUsesWebKitUserInterface(bool preference)
{
- DEFINE_STATIC_LOCAL(String, inspectorLocalizedStringsURL, ());
- return inspectorLocalizedStringsURL;
+ // This matches a similar check in WebInspectorProxyMac.mm. Keep them in sync.
+
+ // Call the soft link framework function to dlopen it, then [NSBundle bundleWithIdentifier:] will work.
+ WebInspectorLibrary();
+
+ if (![[NSBundle bundleWithIdentifier:@"com.apple.WebInspector"] pathForResource:@"Main" ofType:@"html"])
+ return true;
+
+ if (![[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"])
+ return false;
+
+ return preference;
}
-void WebInspector::setLocalizedStringsPath(const String& path)
+void WebInspector::setInspectorUsesWebKitUserInterface(bool flag)
{
- if (!path.isEmpty())
- globalInspectorLocalizedStringsURL() = [[NSURL fileURLWithPath:path] absoluteString];
+ NSString *bundleIdentifier = inspectorReallyUsesWebKitUserInterface(flag) ? @"com.apple.WebCore" : @"com.apple.WebInspector";
+ NSString *path = [[NSBundle bundleWithIdentifier:bundleIdentifier] pathForResource:@"localizedStrings" ofType:@"js"];
+ if ([path length])
+ m_localizedStringsURL = [[NSURL fileURLWithPath:path] absoluteString];
else
- globalInspectorLocalizedStringsURL() = String();
+ m_localizedStringsURL = String();
}
String WebInspector::localizedStringsURL() const
{
- return globalInspectorLocalizedStringsURL();
+ return m_localizedStringsURL;
}
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
index d876a8d45..c6ba01255 100644
--- a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
+++ b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,14 +29,19 @@
#import "AttributedString.h"
#import "DataReference.h"
#import "EditorState.h"
+#import "PDFKitImports.h"
#import "PluginView.h"
+#import "PrintInfo.h"
#import "WKAccessibilityWebPageObject.h"
#import "WebCoreArgumentCoders.h"
#import "WebEvent.h"
#import "WebEventConversion.h"
#import "WebFrame.h"
+#import "WebInspector.h"
#import "WebPageProxyMessages.h"
+#import "WebPreferencesStore.h"
#import "WebProcess.h"
+#import <PDFKit/PDFKit.h>
#import <WebCore/AXObjectCache.h>
#import <WebCore/FocusController.h>
#import <WebCore/Frame.h>
@@ -56,6 +61,7 @@
#import <WebKitSystemInterface.h>
using namespace WebCore;
+using namespace std;
namespace WebKit {
@@ -83,8 +89,10 @@ void WebPage::platformInitialize()
m_mockAccessibilityElement = mockAccessibilityElement;
}
-void WebPage::platformPreferencesDidChange(const WebPreferencesStore&)
+void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
{
+ if (WebInspector* inspector = this->inspector())
+ inspector->setInspectorUsesWebKitUserInterface(store.getBoolValueForKey(WebPreferencesKey::inspectorUsesWebKitUserInterfaceKey()));
}
typedef HashMap<String, String> SelectorNameMap;
@@ -264,10 +272,10 @@ void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uin
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
- RefPtr<Range> replacementRange;
if (replacementRangeStart != NSNotFound) {
- replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
- frame->selection()->setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
+ RefPtr<Range> replacementRange = convertToRange(frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));
+ if (replacementRange)
+ frame->selection()->setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY));
}
if (!frame->editor()->hasComposition()) {
@@ -354,7 +362,7 @@ void WebPage::characterIndexForPoint(IntPoint point, uint64_t& index)
HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(point, false);
frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController()->focusedOrMainFrame();
- RefPtr<Range> range = frame->rangeForPoint(result.point());
+ RefPtr<Range> range = frame->rangeForPoint(result.roundedPoint());
if (!range)
return;
@@ -600,28 +608,43 @@ void WebPage::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference&
[accessibilityRemoteObject() setRemoteParent:remoteElement];
}
-void WebPage::writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes, bool& result)
+void WebPage::readSelectionFromPasteboard(const String& pasteboardName, bool& result)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
if (!frame || frame->selection()->isNone()) {
result = false;
return;
}
- frame->editor()->writeSelectionToPasteboard(pasteboardName, pasteboardTypes);
+ frame->editor()->readSelectionFromPasteboard(pasteboardName);
result = true;
}
-void WebPage::readSelectionFromPasteboard(const String& pasteboardName, bool& result)
+void WebPage::getStringSelectionForPasteboard(String& stringValue)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
- if (!frame || frame->selection()->isNone()) {
- result = false;
+ if (!frame || frame->selection()->isNone())
+ return;
+
+ stringValue = frame->editor()->stringSelectionForPasteboard();
+}
+
+void WebPage::getDataSelectionForPasteboard(const String pasteboardType, SharedMemory::Handle& handle, uint64_t& size)
+{
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame || frame->selection()->isNone())
+ return;
+
+ RefPtr<SharedBuffer> buffer = frame->editor()->dataSelectionForPasteboard(pasteboardType);
+ if (!buffer) {
+ size = 0;
return;
}
- frame->editor()->readSelectionFromPasteboard(pasteboardName);
- result = true;
+ size = buffer->size();
+ RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(size);
+ memcpy(sharedMemoryBuffer->data(), buffer->data(), size);
+ sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly);
}
-
+
WKAccessibilityWebPageObject* WebPage::accessibilityRemoteObject()
{
return m_mockAccessibilityElement.get();
@@ -707,4 +730,120 @@ void WebPage::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& ev
result = !!hitResult.scrollbar();
}
+void WebPage::setLayerHostingMode(LayerHostingMode layerHostingMode)
+{
+ m_layerHostingMode = layerHostingMode;
+
+ for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
+ (*it)->setLayerHostingMode(layerHostingMode);
+}
+
+void WebPage::computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo& printInfo, Vector<IntRect>& resultPageRects)
+{
+ ASSERT(resultPageRects.isEmpty());
+ WebFrame* frame = WebProcess::shared().webFrame(frameID);
+ Frame* coreFrame = frame ? frame->coreFrame() : 0;
+ RetainPtr<PDFDocument> pdfDocument = coreFrame ? pdfDocumentForPrintingFrame(coreFrame) : 0;
+ if ([pdfDocument.get() allowsPrinting]) {
+ NSUInteger pageCount = [pdfDocument.get() pageCount];
+ IntRect pageRect(0, 0, ceilf(printInfo.availablePaperWidth), ceilf(printInfo.availablePaperHeight));
+ for (NSUInteger i = 1; i <= pageCount; ++i) {
+ resultPageRects.append(pageRect);
+ pageRect.move(0, pageRect.height());
+ }
+ }
+}
+
+static inline CGFloat roundCGFloat(CGFloat f)
+{
+ if (sizeof(CGFloat) == sizeof(float))
+ return roundf(static_cast<float>(f));
+ return static_cast<CGFloat>(round(f));
+}
+
+static void drawPDFPage(PDFDocument *pdfDocument, CFIndex pageIndex, CGContextRef context, CGFloat pageSetupScaleFactor, CGSize paperSize)
+{
+ CGContextSaveGState(context);
+
+ CGContextScaleCTM(context, pageSetupScaleFactor, pageSetupScaleFactor);
+
+ PDFPage *pdfPage = [pdfDocument pageAtIndex:pageIndex];
+ NSRect cropBox = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
+ if (NSIsEmptyRect(cropBox))
+ cropBox = [pdfPage boundsForBox:kPDFDisplayBoxMediaBox];
+ else
+ cropBox = NSIntersectionRect(cropBox, [pdfPage boundsForBox:kPDFDisplayBoxMediaBox]);
+
+ bool shouldRotate = (paperSize.width < paperSize.height) != (cropBox.size.width < cropBox.size.height);
+ if (shouldRotate)
+ swap(cropBox.size.width, cropBox.size.height);
+
+ // Center.
+ CGFloat widthDifference = paperSize.width / pageSetupScaleFactor - cropBox.size.width;
+ CGFloat heightDifference = paperSize.height / pageSetupScaleFactor - cropBox.size.height;
+ if (widthDifference || heightDifference)
+ CGContextTranslateCTM(context, roundCGFloat(widthDifference / 2), roundCGFloat(heightDifference / 2));
+
+ if (shouldRotate) {
+ CGContextRotateCTM(context, static_cast<CGFloat>(piOverTwoDouble));
+ CGContextTranslateCTM(context, 0, -cropBox.size.width);
+ }
+
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]];
+ [pdfPage drawWithBox:kPDFDisplayBoxCropBox];
+ [NSGraphicsContext restoreGraphicsState];
+
+ CGAffineTransform transform = CGContextGetCTM(context);
+
+ for (PDFAnnotation *annotation in [pdfPage annotations]) {
+ if (![annotation isKindOfClass:pdfAnnotationLinkClass()])
+ continue;
+
+ PDFAnnotationLink *linkAnnotation = (PDFAnnotationLink *)annotation;
+ NSURL *url = [linkAnnotation URL];
+ if (!url)
+ continue;
+
+ CGRect urlRect = NSRectToCGRect([linkAnnotation bounds]);
+ CGRect transformedRect = CGRectApplyAffineTransform(urlRect, transform);
+ CGPDFContextSetURLForRect(context, (CFURLRef)url, transformedRect);
+ }
+
+ CGContextRestoreGState(context);
+}
+
+void WebPage::drawRectToPDFFromPDFDocument(CGContextRef context, PDFDocument *pdfDocument, const PrintInfo& printInfo, const WebCore::IntRect& rect)
+{
+ NSUInteger pageCount = [pdfDocument pageCount];
+ IntSize paperSize(ceilf(printInfo.availablePaperWidth), ceilf(printInfo.availablePaperHeight));
+ IntRect pageRect(IntPoint(), paperSize);
+ for (NSUInteger i = 0; i < pageCount; ++i) {
+ if (pageRect.intersects(rect)) {
+ CGContextSaveGState(context);
+
+ CGContextTranslateCTM(context, pageRect.x() - rect.x(), pageRect.y() - rect.y());
+ drawPDFPage(pdfDocument, i, context, printInfo.pageSetupScaleFactor, paperSize);
+
+ CGContextRestoreGState(context);
+ }
+ pageRect.move(0, pageRect.height());
+ }
+}
+
+void WebPage::drawPagesToPDFFromPDFDocument(CGContextRef context, PDFDocument *pdfDocument, const PrintInfo& printInfo, uint32_t first, uint32_t count)
+{
+ NSUInteger pageCount = [pdfDocument pageCount];
+ for (uint32_t page = first; page < first + count; ++page) {
+ if (page >= pageCount)
+ break;
+
+ RetainPtr<CFDictionaryRef> pageInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+
+ CGPDFContextBeginPage(context, pageInfo.get());
+ drawPDFPage(pdfDocument, page, context, printInfo.pageSetupScaleFactor, CGSizeMake(printInfo.availablePaperWidth, printInfo.availablePaperHeight));
+ CGPDFContextEndPage(context);
+ }
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
index 213743003..964366e8d 100644
--- a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
@@ -32,11 +32,17 @@
#include "GraphicsContext.h"
#include "LayerTreeHostProxyMessages.h"
#include "MessageID.h"
+#include "SurfaceUpdateInfo.h"
+#include "WebCoreArgumentCoders.h"
#include "WebGraphicsLayer.h"
#include "WebPage.h"
#include <WebCore/Frame.h>
#include <WebCore/FrameView.h>
#include <WebCore/Page.h>
+#include <WebCore/RenderLayer.h>
+#include <WebCore/RenderLayerBacking.h>
+#include <WebCore/RenderLayerCompositor.h>
+#include <WebCore/RenderView.h>
#include <WebCore/Settings.h>
using namespace WebCore;
@@ -63,11 +69,10 @@ LayerTreeHostQt::LayerTreeHostQt(WebPage* webPage)
: LayerTreeHost(webPage)
, m_notifyAfterScheduledLayerFlush(false)
, m_isValid(true)
-#if USE(TILED_BACKING_STORE)
, m_waitingForUIProcess(false)
, m_isSuspended(false)
, m_contentsScale(1)
-#endif
+ , m_shouldSendScrollPositionUpdate(true)
, m_shouldSyncFrame(false)
, m_shouldSyncRootLayer(true)
, m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
@@ -85,9 +90,7 @@ LayerTreeHostQt::LayerTreeHostQt(WebPage* webPage)
m_layerTreeContext.webLayerID = toWebGraphicsLayer(webRootLayer)->id();
m_nonCompositedContentLayer = GraphicsLayer::create(this);
-#if USE(TILED_BACKING_STORE)
toWebGraphicsLayer(m_rootLayer.get())->setWebGraphicsLayerClient(this);
-#endif
#ifndef NDEBUG
m_nonCompositedContentLayer->setName("LayerTreeHostQt non-composited content");
#endif
@@ -176,6 +179,9 @@ void LayerTreeHostQt::forceRepaint()
void LayerTreeHostQt::sizeDidChange(const WebCore::IntSize& newSize)
{
+ if (m_rootLayer->size() == newSize)
+ return;
+
m_rootLayer->setSize(newSize);
// If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
@@ -216,6 +222,13 @@ void LayerTreeHostQt::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect)
scheduleLayerFlush();
}
+void LayerTreeHostQt::setPageOverlayOpacity(float value)
+{
+ ASSERT(m_pageOverlayLayer);
+ m_pageOverlayLayer->setOpacity(value);
+ scheduleLayerFlush();
+}
+
bool LayerTreeHostQt::flushPendingLayerChanges()
{
bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
@@ -227,12 +240,30 @@ bool LayerTreeHostQt::flushPendingLayerChanges()
return didSync;
}
-void LayerTreeHostQt::didSyncCompositingStateForLayer(const WebLayerInfo& info)
+void LayerTreeHostQt::syncLayerState(WebLayerID id, const WebLayerInfo& info)
+{
+ if (m_shouldSendScrollPositionUpdate) {
+ m_webPage->send(Messages::LayerTreeHostProxy::DidChangeScrollPosition(m_visibleContentsRect.location()));
+ m_shouldSendScrollPositionUpdate = false;
+ }
+ m_shouldSyncFrame = true;
+ m_webPage->send(Messages::LayerTreeHostProxy::SetCompositingLayerState(id, info));
+}
+
+void LayerTreeHostQt::syncLayerChildren(WebLayerID id, const Vector<WebLayerID>& children)
{
m_shouldSyncFrame = true;
- m_webPage->send(Messages::LayerTreeHostProxy::SyncCompositingLayerState(info));
+ m_webPage->send(Messages::LayerTreeHostProxy::SetCompositingLayerChildren(id, children));
}
+#if ENABLE(CSS_FILTERS)
+void LayerTreeHostQt::syncLayerFilters(WebLayerID id, const FilterOperations& filters)
+{
+ m_shouldSyncFrame = true;
+ m_webPage->send(Messages::LayerTreeHostProxy::SetCompositingLayerFilters(id, filters));
+}
+#endif
+
void LayerTreeHostQt::attachLayer(WebGraphicsLayer* layer)
{
ASSERT(!m_registeredLayers.contains(layer));
@@ -249,12 +280,58 @@ void LayerTreeHostQt::detachLayer(WebGraphicsLayer* layer)
m_webPage->send(Messages::LayerTreeHostProxy::DeleteCompositingLayer(layer->id()));
}
+static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer)
+{
+ // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition.
+ RenderLayerBacking* backing = renderLayer->backing();
+ if (!backing)
+ return;
+
+ RenderStyle* style = renderLayer->renderer()->style();
+ if (!style)
+ return;
+
+ if (!renderLayer->renderer()->isPositioned() || renderLayer->renderer()->style()->position() != FixedPosition)
+ return;
+
+ if (!renderLayer->renderer()->container()->isRenderView())
+ return;
+
+ if (!renderLayer->isStackingContext())
+ return;
+
+ WebGraphicsLayer* graphicsLayer = toWebGraphicsLayer(backing->graphicsLayer());
+ graphicsLayer->setFixedToViewport(true);
+}
+
+static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer)
+{
+ updateOffsetFromViewportForSelf(renderLayer);
+
+ if (renderLayer->firstChild())
+ updateOffsetFromViewportForLayer(renderLayer->firstChild());
+ if (renderLayer->nextSibling())
+ updateOffsetFromViewportForLayer(renderLayer->nextSibling());
+}
+
+void LayerTreeHostQt::syncFixedLayers()
+{
+ if (!m_webPage->corePage()->settings() || !m_webPage->corePage()->settings()->acceleratedCompositingForFixedPositionEnabled())
+ return;
+
+ if (!m_webPage->mainFrame()->view()->hasFixedObjects())
+ return;
+
+ RenderLayer* rootRenderLayer = m_webPage->mainFrame()->contentRenderer()->compositor()->rootRenderLayer();
+ ASSERT(rootRenderLayer);
+ if (rootRenderLayer->firstChild())
+ updateOffsetFromViewportForLayer(rootRenderLayer->firstChild());
+}
+
void LayerTreeHostQt::performScheduledLayerFlush()
{
-#if USE(TILED_BACKING_STORE)
if (m_isSuspended || m_waitingForUIProcess)
return;
-#endif
m_webPage->layoutIfNeeded();
@@ -326,7 +403,7 @@ int64_t LayerTreeHostQt::adoptImageBackingStore(Image* image)
return key;
}
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0);
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), (image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0));
{
OwnPtr<WebCore::GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
graphicsContext->drawImage(image, ColorSpaceDeviceRGB, IntPoint::zero());
@@ -395,18 +472,21 @@ bool LayerTreeHost::supportsAcceleratedCompositing()
return true;
}
-void LayerTreeHostQt::createTile(WebLayerID layerID, int tileID, const UpdateInfo& updateInfo)
+void LayerTreeHostQt::createTile(WebLayerID layerID, int tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& targetRect)
{
- m_webPage->send(Messages::LayerTreeHostProxy::CreateTileForLayer(layerID, tileID, updateInfo));
+ m_shouldSyncFrame = true;
+ m_webPage->send(Messages::LayerTreeHostProxy::CreateTileForLayer(layerID, tileID, targetRect, updateInfo));
}
-void LayerTreeHostQt::updateTile(WebLayerID layerID, int tileID, const UpdateInfo& updateInfo)
+void LayerTreeHostQt::updateTile(WebLayerID layerID, int tileID, const SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& targetRect)
{
- m_webPage->send(Messages::LayerTreeHostProxy::UpdateTileForLayer(layerID, tileID, updateInfo));
+ m_shouldSyncFrame = true;
+ m_webPage->send(Messages::LayerTreeHostProxy::UpdateTileForLayer(layerID, tileID, targetRect, updateInfo));
}
void LayerTreeHostQt::removeTile(WebLayerID layerID, int tileID)
{
+ m_shouldSyncFrame = true;
m_webPage->send(Messages::LayerTreeHostProxy::RemoveTileForLayer(layerID, tileID));
}
@@ -415,32 +495,40 @@ WebCore::IntRect LayerTreeHostQt::visibleContentsRect() const
return m_visibleContentsRect;
}
-void LayerTreeHostQt::setVisibleContentsRectForScaling(const IntRect& rect, float scale)
+void LayerTreeHostQt::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector)
{
- m_visibleContentsRect = rect;
- m_contentsScale = scale;
+ bool contentsRectDidChange = rect != m_visibleContentsRect;
+ bool contentsScaleDidChange = scale != m_contentsScale;
- HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
- for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) {
- (*it)->setContentsScale(scale);
- (*it)->adjustVisibleRect();
- }
- scheduleLayerFlush();
-}
+ if (trajectoryVector != FloatPoint::zero())
+ toWebGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
-void LayerTreeHostQt::setVisibleContentsRectForPanning(const IntRect& rect, const FloatPoint& trajectoryVector)
-{
- m_visibleContentsRect = rect;
+ if (contentsRectDidChange || contentsScaleDidChange) {
+ m_visibleContentsRect = rect;
+ m_contentsScale = scale;
- toWebGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
+ HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
+ for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) {
+ if (contentsScaleDidChange)
+ (*it)->setContentsScale(scale);
+ if (contentsRectDidChange)
+ (*it)->adjustVisibleRect();
+ }
+ }
scheduleLayerFlush();
+ if (m_webPage->useFixedLayout())
+ m_webPage->setFixedVisibleContentRect(rect);
+ if (contentsRectDidChange)
+ m_shouldSendScrollPositionUpdate = true;
}
void LayerTreeHostQt::renderNextFrame()
{
m_waitingForUIProcess = false;
scheduleLayerFlush();
+ for (int i = 0; i < m_updateAtlases.size(); ++i)
+ m_updateAtlases[i].didSwapBuffers();
}
bool LayerTreeHostQt::layerTreeTileUpdatesAllowed() const
@@ -455,6 +543,32 @@ void LayerTreeHostQt::purgeBackingStores()
(*it)->purgeBackingStores();
ASSERT(!m_directlyCompositedImageRefCounts.size());
+ m_updateAtlases.clear();
+}
+
+UpdateAtlas& LayerTreeHostQt::getAtlas(ShareableBitmap::Flags flags)
+{
+ for (int i = 0; i < m_updateAtlases.size(); ++i) {
+ if (m_updateAtlases[i].flags() == flags)
+ return m_updateAtlases[i];
+ }
+ static const int ScratchBufferDimension = 2000;
+ m_updateAtlases.append(UpdateAtlas(ScratchBufferDimension, flags));
+ return m_updateAtlases.last();
+}
+
+PassOwnPtr<WebCore::GraphicsContext> LayerTreeHostQt::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, ShareableSurface::Handle& handle, WebCore::IntPoint& offset)
+{
+ UpdateAtlas& atlas = getAtlas(flags);
+ if (!atlas.surface()->createHandle(handle))
+ return PassOwnPtr<WebCore::GraphicsContext>();
+
+ // This will return null if there is no available buffer.
+ OwnPtr<WebCore::GraphicsContext> graphicsContext = atlas.beginPaintingOnAvailableBuffer(size, offset);
+ if (!graphicsContext)
+ return PassOwnPtr<WebCore::GraphicsContext>();
+
+ return graphicsContext.release();
}
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
index 9db85b78d..eecb62e63 100644
--- a/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
+++ b/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
@@ -23,6 +23,7 @@
#include "LayerTreeContext.h"
#include "LayerTreeHost.h"
#include "Timer.h"
+#include "UpdateAtlas.h"
#include "WebGraphicsLayer.h"
#include <WebCore/GraphicsLayerClient.h>
#include <wtf/OwnPtr.h>
@@ -56,6 +57,8 @@ public:
virtual void didInstallPageOverlay();
virtual void didUninstallPageOverlay();
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&);
+ virtual void setPageOverlayOpacity(float);
+ virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return false; }
virtual void pauseRendering() { m_isSuspended = true; }
virtual void resumeRendering() { m_isSuspended = false; scheduleLayerFlush(); }
@@ -63,18 +66,24 @@ public:
virtual int64_t adoptImageBackingStore(WebCore::Image*);
virtual void releaseImageBackingStore(int64_t);
- virtual void createTile(WebLayerID, int tileID, const UpdateInfo&);
- virtual void updateTile(WebLayerID, int tileID, const UpdateInfo&);
+ virtual void createTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&);
+ virtual void updateTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&);
virtual void removeTile(WebLayerID, int tileID);
virtual WebCore::IntRect visibleContentsRect() const;
virtual void renderNextFrame();
virtual void purgeBackingStores();
virtual bool layerTreeTileUpdatesAllowed() const;
- virtual void setVisibleContentsRectForScaling(const WebCore::IntRect&, float scale);
- virtual void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&);
- virtual void didSyncCompositingStateForLayer(const WebLayerInfo&);
+ virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&);
+ virtual void syncLayerState(WebLayerID, const WebLayerInfo&);
+ virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&);
+#if ENABLE(CSS_FILTERS)
+ virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&);
+#endif
virtual void attachLayer(WebCore::WebGraphicsLayer*);
virtual void detachLayer(WebCore::WebGraphicsLayer*);
+ virtual void syncFixedLayers();
+
+ virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&);
protected:
explicit LayerTreeHostQt(WebPage*);
@@ -95,6 +104,8 @@ private:
void performScheduledLayerFlush();
void sendLayersToUI();
+ UpdateAtlas& getAtlas(ShareableBitmap::Flags);
+
OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
// The layer which contains all non-composited content.
@@ -105,6 +116,7 @@ private:
HashSet<WebCore::WebGraphicsLayer*> m_registeredLayers;
HashMap<int64_t, int> m_directlyCompositedImageRefCounts;
+ Vector<UpdateAtlas> m_updateAtlases;
bool m_notifyAfterScheduledLayerFlush;
bool m_isValid;
@@ -113,6 +125,7 @@ private:
bool m_isSuspended;
WebCore::IntRect m_visibleContentsRect;
float m_contentsScale;
+ bool m_shouldSendScrollPositionUpdate;
LayerTreeContext m_layerTreeContext;
bool m_shouldSyncFrame;
diff --git a/Source/WebKit2/WebProcess/WebProcess.cpp b/Source/WebKit2/WebProcess/WebProcess.cpp
index 9a8b905fe..c435221a7 100644
--- a/Source/WebKit2/WebProcess/WebProcess.cpp
+++ b/Source/WebKit2/WebProcess/WebProcess.cpp
@@ -135,19 +135,25 @@ WebProcess::WebProcess()
#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
, m_compositingRenderServerPort(MACH_PORT_NULL)
#endif
+#if PLATFORM(MAC)
+ , m_clearResourceCachesDispatchGroup(0)
+#endif
, m_fullKeyboardAccessEnabled(false)
#if PLATFORM(QT)
, m_networkAccessManager(0)
#endif
, m_textCheckerState()
, m_geolocationManager(this)
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
, m_notificationManager(this)
#endif
, m_iconDatabaseProxy(this)
#if ENABLE(PLUGIN_PROCESS)
, m_disablePluginProcessMessageTimeout(false)
#endif
+#if USE(SOUP)
+ , m_soupRequestManager(this)
+#endif
{
#if USE(PLATFORM_STRATEGIES)
// Initialize our platform strategies.
@@ -503,7 +509,7 @@ WebPage* WebProcess::focusedWebPage() const
HashMap<uint64_t, RefPtr<WebPage> >::const_iterator end = m_pageMap.end();
for (HashMap<uint64_t, RefPtr<WebPage> >::const_iterator it = m_pageMap.begin(); it != end; ++it) {
WebPage* page = (*it).second.get();
- if (page->windowIsFocused())
+ if (page->windowAndWebPageAreFocused())
return page;
}
return 0;
@@ -518,16 +524,16 @@ void WebProcess::createWebPage(uint64_t pageID, const WebPageCreationParameters&
{
// It is necessary to check for page existence here since during a window.open() (or targeted
// link) the WebPage gets created both in the synchronous handler and through the normal way.
- std::pair<HashMap<uint64_t, RefPtr<WebPage> >::iterator, bool> result = m_pageMap.add(pageID, 0);
- if (result.second) {
- ASSERT(!result.first->second);
- result.first->second = WebPage::create(pageID, parameters);
+ HashMap<uint64_t, RefPtr<WebPage> >::AddResult result = m_pageMap.add(pageID, 0);
+ if (result.isNewEntry) {
+ ASSERT(!result.iterator->second);
+ result.iterator->second = WebPage::create(pageID, parameters);
// Balanced by an enableTermination in removeWebPage.
disableTermination();
}
- ASSERT(result.first->second);
+ ASSERT(result.iterator->second);
}
void WebProcess::removeWebPage(uint64_t pageID)
@@ -638,7 +644,7 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
return;
}
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
if (messageID.is<CoreIPC::MessageClassWebNotificationManager>()) {
m_notificationManager.didReceiveMessage(connection, messageID, arguments);
return;
@@ -650,6 +656,13 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
return;
}
+#if USE(SOUP)
+ if (messageID.is<CoreIPC::MessageClassWebSoupRequestManager>()) {
+ m_soupRequestManager.didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+#endif
+
if (messageID.is<CoreIPC::MessageClassInjectedBundle>()) {
if (!m_injectedBundle)
return;
@@ -683,7 +696,7 @@ void WebProcess::didClose(CoreIPC::Connection*)
pages[i]->close();
pages.clear();
- gcController().garbageCollectNow();
+ gcController().garbageCollectSoon();
memoryCache()->setDisabled(true);
#endif
@@ -739,13 +752,13 @@ WebPageGroupProxy* WebProcess::webPageGroup(uint64_t pageGroupID)
WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupData)
{
- std::pair<HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::iterator, bool> result = m_pageGroupMap.add(pageGroupData.pageGroupID, 0);
- if (result.second) {
- ASSERT(!result.first->second);
- result.first->second = WebPageGroupProxy::create(pageGroupData);
+ HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::AddResult result = m_pageGroupMap.add(pageGroupData.pageGroupID, 0);
+ if (result.isNewEntry) {
+ ASSERT(!result.iterator->second);
+ result.iterator->second = WebPageGroupProxy::create(pageGroupData);
}
- return result.first->second.get();
+ return result.iterator->second.get();
}
static bool canPluginHandleResponse(const ResourceResponse& response)
diff --git a/Source/WebKit2/WebProcess/WebProcess.h b/Source/WebKit2/WebProcess/WebProcess.h
index efa2e681a..eafe1d99b 100644
--- a/Source/WebKit2/WebProcess/WebProcess.h
+++ b/Source/WebKit2/WebProcess/WebProcess.h
@@ -44,11 +44,19 @@
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#if USE(SOUP)
+#include "WebSoupRequestManager.h"
+#endif
+
#if PLATFORM(QT)
class QNetworkAccessManager;
#endif
-#if ENABLE(NOTIFICATIONS)
+#if PLATFORM(MAC)
+#include <dispatch/dispatch.h>
+#endif
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#include "WebNotificationManager.h"
#endif
@@ -133,7 +141,7 @@ public:
// Geolocation
WebGeolocationManager& geolocationManager() { return m_geolocationManager; }
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
WebNotificationManager& notificationManager() { return m_notificationManager; }
#endif
@@ -148,6 +156,10 @@ public:
EventDispatcher& eventDispatcher() { return m_eventDispatcher; }
+#if USE(SOUP)
+ WebSoupRequestManager& soupRequestManager() { return m_soupRequestManager; }
+#endif
+
private:
WebProcess();
@@ -254,6 +266,7 @@ private:
#endif
#if PLATFORM(MAC)
pid_t m_presenterApplicationPid;
+ dispatch_group_t m_clearResourceCachesDispatchGroup;
#endif
bool m_fullKeyboardAccessEnabled;
@@ -268,7 +281,7 @@ private:
TextCheckerState m_textCheckerState;
WebGeolocationManager m_geolocationManager;
-#if ENABLE(NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
WebNotificationManager m_notificationManager;
#endif
WebIconDatabaseProxy m_iconDatabaseProxy;
@@ -282,6 +295,10 @@ private:
bool m_disablePluginProcessMessageTimeout;
#endif
+#if USE(SOUP)
+ WebSoupRequestManager m_soupRequestManager;
+#endif
+
};
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in
index 68b073bd8..b38c23c6c 100644
--- a/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in
+++ b/Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in
@@ -93,11 +93,14 @@
(allow file*
(subpath "/private/var/db/mds/system"))
-;; FIXME: <rdar://problem/10792047> Use private user cache directory
+#if !defined(BUILDING_ON_LION)
+(if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
+ (allow file* (subpath (param "DARWIN_USER_CACHE_DIR"))))
+#else
(if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
(allow file* (subpath (string-append (param "DARWIN_USER_CACHE_DIR") "/mds"))))
+#endif
-;; FIXME: <rdar://problem/10785457> Use private temporary directory
(if (positive? (string-length (param "DARWIN_USER_TEMP_DIR")))
(allow file* (subpath (param "DARWIN_USER_TEMP_DIR"))))
diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm
index 7d0d69c26..69f4fb10b 100644
--- a/Source/WebKit2/WebProcess/mac/WebProcessMac.mm
+++ b/Source/WebKit2/WebProcess/mac/WebProcessMac.mm
@@ -130,7 +130,13 @@ void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear
{
if (cachesToClear == InMemoryResourceCachesOnly)
return;
- [[NSURLCache sharedURLCache] removeAllCachedResponses];
+
+ if (!m_clearResourceCachesDispatchGroup)
+ m_clearResourceCachesDispatchGroup = dispatch_group_create();
+
+ dispatch_group_async(m_clearResourceCachesDispatchGroup, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ [[NSURLCache sharedURLCache] removeAllCachedResponses];
+ });
}
#if ENABLE(WEB_PROCESS_SANDBOX)
@@ -175,10 +181,22 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
{
#if ENABLE(WEB_PROCESS_SANDBOX)
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisableSandbox"]) {
- fprintf(stderr, "Bypassing sandbox due to DisableSandbox user default.\n");
+ WTFLogAlways("Bypassing sandbox due to DisableSandbox user default.\n");
return;
}
+#if !defined(BUILDING_ON_LION)
+ // Use private temporary and cache directories.
+ String systemDirectorySuffix = "com.apple.WebProcess+" + parameters.uiProcessBundleIdentifier;
+ setenv("DIRHELPER_USER_DIR_SUFFIX", fileSystemRepresentation(systemDirectorySuffix).data(), 0);
+ char temporaryDirectory[PATH_MAX];
+ if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
+ WTFLogAlways("WebProcess: couldn't retrieve private temporary directory path: %d\n", errno);
+ exit(EX_NOPERM);
+ }
+ setenv("TMPDIR", temporaryDirectory, 1);
+#endif
+
Vector<const char*> sandboxParameters;
// These are read-only.
@@ -203,9 +221,9 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
char* errorBuf;
if (sandbox_init_with_parameters(profilePath, SANDBOX_NAMED_EXTERNAL, sandboxParameters.data(), &errorBuf)) {
- fprintf(stderr, "WebProcess: couldn't initialize sandbox profile [%s]\n", profilePath);
+ WTFLogAlways("WebProcess: couldn't initialize sandbox profile [%s] error '%s'\n", profilePath, errorBuf);
for (size_t i = 0; sandboxParameters[i]; i += 2)
- fprintf(stderr, "%s=%s\n", sandboxParameters[i], sandboxParameters[i + 1]);
+ WTFLogAlways("%s=%s\n", sandboxParameters[i], sandboxParameters[i + 1]);
exit(EX_NOPERM);
}
@@ -215,7 +233,7 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
// This will override LSFileQuarantineEnabled from Info.plist unless sandbox quarantine is globally disabled.
OSStatus error = WKEnableSandboxStyleFileQuarantine();
if (error) {
- fprintf(stderr, "WebProcess: couldn't enable sandbox style file quarantine: %ld\n", (long)error);
+ WTFLogAlways("WebProcess: couldn't enable sandbox style file quarantine: %ld\n", (long)error);
exit(EX_NOPERM);
}
#endif
@@ -249,11 +267,9 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
[NSURLCache setSharedURLCache:parentProcessURLCache.get()];
}
- WebInspector::setLocalizedStringsPath(parameters.webInspectorLocalizedStringsPath);
-
m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
-
-#if ENABLE(NOTIFICATIONS)
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
m_notificationManager.initialize(parameters.notificationPermissions);
#endif
@@ -274,6 +290,11 @@ void WebProcess::initializeShim()
void WebProcess::platformTerminate()
{
+ if (m_clearResourceCachesDispatchGroup) {
+ dispatch_group_wait(m_clearResourceCachesDispatchGroup, DISPATCH_TIME_FOREVER);
+ dispatch_release(m_clearResourceCachesDispatchGroup);
+ m_clearResourceCachesDispatchGroup = 0;
+ }
}
void WebProcess::secItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecItemResponseData& response)
diff --git a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm
index 4e2b15532..ddbba9f15 100644
--- a/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm
+++ b/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm
@@ -84,7 +84,7 @@ int WebProcessMain(const CommandLine& commandLine)
if (clientExecutable.isEmpty()) {
kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort);
if (kr) {
- fprintf(stderr, "bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
+ WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
return 2;
}
}
@@ -96,7 +96,7 @@ int WebProcessMain(const CommandLine& commandLine)
// Make it possible to look up.
serviceName = String::format("com.apple.WebKit.WebProcess-%d", getpid());
if (kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.utf8().data()), publishedService, 0)) {
- fprintf(stderr, "Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr);
+ WTFLogAlways("Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr);
return EXIT_FAILURE;
}
@@ -118,12 +118,16 @@ int WebProcessMain(const CommandLine& commandLine)
posix_spawnattr_setflags(&attributes, POSIX_SPAWN_CLOEXEC_DEFAULT | POSIX_SPAWN_SETPGROUP);
int spawnResult = posix_spawn(0, command.data(), &fileActions, &attributes, const_cast<char**>(args), environmentVariables.environmentPointer());
+
+ posix_spawnattr_destroy(&attributes);
+ posix_spawn_file_actions_destroy(&fileActions);
+
if (spawnResult)
return 2;
mach_msg_empty_rcv_t message;
if (kern_return_t kr = mach_msg(&message.header, MACH_RCV_MSG, 0, sizeof(message), publishedService, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL)) {
- fprintf(stderr, "Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr);
+ WTFLogAlways("Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr);
return EXIT_FAILURE;
}
@@ -132,7 +136,7 @@ int WebProcessMain(const CommandLine& commandLine)
mach_port_type_t portType;
kern_return_t kr = mach_port_type(mach_task_self(), serverPort, &portType);
if (kr || !(portType & MACH_PORT_TYPE_SEND)) {
- fprintf(stderr, "Failed to obtain send right for port received from the UI process.\n");
+ WTFLogAlways("Failed to obtain send right for port received from the UI process.\n");
return EXIT_FAILURE;
}
}
diff --git a/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp b/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp
index 4a2d55491..c00a73c19 100644
--- a/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp
+++ b/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp
@@ -69,6 +69,11 @@ QtBuiltinBundlePage::QtBuiltinBundlePage(QtBuiltinBundle* bundle, WKBundlePageRe
0, // didLayoutForFrame
0, // didNewFirstVisuallyNonEmptyLayoutForFrame
0, // didDetectXSSForFrame
+ 0, // shouldGoToBackForwardListItem
+ 0, // didCreateGlobalObjectForFrame
+ 0, // willDisconnectDOMWindowExtensionFromGlobalObject
+ 0, // didReconnectDOMWindowExtensionToGlobalObject
+ 0, // willDestroyGlobalObjectForDOMWindowExtension
};
WKBundlePageSetPageLoaderClient(m_page, &loaderClient);
}
diff --git a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp
index 91e7ae437..99eb68185 100644
--- a/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp
+++ b/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp
@@ -25,19 +25,17 @@
*/
#include "config.h"
-
#include "WebProcess.h"
-#include <WebCore/RunLoop.h>
-#include <runtime/InitializeThreading.h>
-#include <wtf/MainThread.h>
-#include <QApplication>
+#include <QGuiApplication>
#include <QList>
#include <QNetworkProxyFactory>
#include <QString>
#include <QStringList>
#include <QUrl>
-#include <QtGlobal>
+#include <WebCore/RunLoop.h>
+#include <runtime/InitializeThreading.h>
+#include <wtf/MainThread.h>
#if USE(ACCELERATED_COMPOSITING)
#include "WebGraphicsLayer.h"
@@ -141,33 +139,8 @@ static void initializeProxy()
QNetworkProxyFactory::setUseSystemConfiguration(true);
}
-void messageHandler(QtMsgType type, const char* message)
-{
- if (type == QtCriticalMsg) {
- fprintf(stderr, "%s\n", message);
- return;
- }
-
- // Do nothing
-}
-
-Q_DECL_EXPORT int WebProcessMainQt(int argc, char** argv)
+Q_DECL_EXPORT int WebProcessMainQt(QGuiApplication* app)
{
- // Has to be done before QApplication is constructed in case
- // QApplication itself produces debug output.
- QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT");
- if (!suppressOutput.isEmpty() && suppressOutput != "0")
- qInstallMsgHandler(messageHandler);
-
- QApplication::setGraphicsSystem(QLatin1String("raster"));
- QApplication* app = new QApplication(argc, argv);
-#ifndef NDEBUG
- if (qgetenv("QT_WEBKIT2_DEBUG") == "1") {
- qDebug() << "Waiting 3 seconds for debugger";
- sleep(3);
- }
-#endif
-
initializeProxy();
srandom(time(0));
@@ -209,6 +182,7 @@ Q_DECL_EXPORT int WebProcessMainQt(int argc, char** argv)
RunLoop::run();
// FIXME: Do more cleanup here.
+ delete app;
return 0;
}
diff --git a/Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.cpp b/Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.cpp
new file mode 100644
index 000000000..8089096a5
--- /dev/null
+++ b/Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 library 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 library; 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 "WebKitSoupRequestGeneric.h"
+
+#include "WebProcess.h"
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+G_DEFINE_TYPE(WebKitSoupRequestGeneric, webkit_soup_request_generic, SOUP_TYPE_REQUEST)
+
+struct _WebKitSoupRequestGenericPrivate {
+ CString mimeType;
+ goffset contentLength;
+};
+
+static void webkitSoupRequestGenericFinalize(GObject* object)
+{
+ WEBKIT_SOUP_REQUEST_GENERIC(object)->priv->~WebKitSoupRequestGenericPrivate();
+ G_OBJECT_CLASS(webkit_soup_request_generic_parent_class)->finalize(object);
+}
+
+static void webkit_soup_request_generic_init(WebKitSoupRequestGeneric* request)
+{
+ WebKitSoupRequestGenericPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_SOUP_REQUEST_GENERIC, WebKitSoupRequestGenericPrivate);
+ request->priv = priv;
+ new (priv) WebKitSoupRequestGenericPrivate();
+}
+
+static void webkitSoupRequestGenericSendAsync(SoupRequest* request, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+{
+ GSimpleAsyncResult* result = g_simple_async_result_new(G_OBJECT(request), callback, userData, reinterpret_cast<void*>(webkitSoupRequestGenericSendAsync));
+ WebProcess::shared().soupRequestManager().send(result);
+}
+
+static GInputStream* webkitSoupRequestGenericSendFinish(SoupRequest* request, GAsyncResult* result, GError** error)
+{
+ GSimpleAsyncResult* simpleResult = G_SIMPLE_ASYNC_RESULT(result);
+ g_warn_if_fail(g_simple_async_result_get_source_tag(simpleResult) == webkitSoupRequestGenericSendAsync);
+
+ if (g_simple_async_result_propagate_error(simpleResult, error))
+ return 0;
+
+ return WebProcess::shared().soupRequestManager().finish(simpleResult);
+}
+
+static goffset webkitSoupRequestGenericGetContentLength(SoupRequest* request)
+{
+ return WEBKIT_SOUP_REQUEST_GENERIC(request)->priv->contentLength;
+}
+
+static const char* webkitSoupRequestGenericGetContentType(SoupRequest* request)
+{
+ return WEBKIT_SOUP_REQUEST_GENERIC(request)->priv->mimeType.data();
+}
+
+static void webkit_soup_request_generic_class_init(WebKitSoupRequestGenericClass* requestGenericClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(requestGenericClass);
+ gObjectClass->finalize = webkitSoupRequestGenericFinalize;
+
+ SoupRequestClass* requestClass = SOUP_REQUEST_CLASS(requestGenericClass);
+ requestClass->send_async = webkitSoupRequestGenericSendAsync;
+ requestClass->send_finish = webkitSoupRequestGenericSendFinish;
+ requestClass->get_content_length = webkitSoupRequestGenericGetContentLength;
+ requestClass->get_content_type = webkitSoupRequestGenericGetContentType;
+
+ g_type_class_add_private(requestGenericClass, sizeof(WebKitSoupRequestGenericPrivate));
+}
+
+void webkitSoupRequestGenericSetContentLength(WebKitSoupRequestGeneric* request, goffset contentLength)
+{
+ request->priv->contentLength = contentLength;
+}
+
+void webkitSoupRequestGenericSetContentType(WebKitSoupRequestGeneric* request, const char* mimeType)
+{
+ request->priv->mimeType = mimeType;
+}
diff --git a/Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.h b/Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.h
new file mode 100644
index 000000000..cee286c37
--- /dev/null
+++ b/Source/WebKit2/WebProcess/soup/WebKitSoupRequestGeneric.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 library 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 library; 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 WebKitSoupRequestGeneric_h
+#define WebKitSoupRequestGeneric_h
+
+#include <glib-object.h>
+#define LIBSOUP_USE_UNSTABLE_REQUEST_API
+#include <libsoup/soup-request.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_SOUP_REQUEST_GENERIC (webkit_soup_request_generic_get_type())
+#define WEBKIT_SOUP_REQUEST_GENERIC(object) (G_TYPE_CHECK_INSTANCE_CAST((object), WEBKIT_TYPE_SOUP_REQUEST_GENERIC, WebKitSoupRequestGeneric))
+#define WEBKIT_IS_SOUP_REQUEST_GENERIC(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), WEBKIT_TYPE_SOUP_REQUEST_GENERIC))
+#define WEBKIT_SOUP_REQUEST_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SOUP_REQUEST_GENERIC, WebKitSoupRequestGenericClass))
+#define WEBKIT_IS_SOUP_REQUEST_GENERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SOUP_REQUEST_GENERIC))
+#define WEBKIT_SOUP_REQUEST_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SOUP_REQUEST_GENERIC, WebKitSoupRequestGenericClass))
+
+typedef struct _WebKitSoupRequestGeneric WebKitSoupRequestGeneric;
+typedef struct _WebKitSoupRequestGenericClass WebKitSoupRequestGenericClass;
+typedef struct _WebKitSoupRequestGenericPrivate WebKitSoupRequestGenericPrivate;
+
+struct _WebKitSoupRequestGeneric {
+ SoupRequest parent;
+
+ WebKitSoupRequestGenericPrivate *priv;
+};
+
+struct _WebKitSoupRequestGenericClass {
+ SoupRequestClass parent;
+};
+
+GType webkit_soup_request_generic_get_type();
+
+void webkitSoupRequestGenericSetContentLength(WebKitSoupRequestGeneric*, goffset contentLength);
+void webkitSoupRequestGenericSetContentType(WebKitSoupRequestGeneric*, const char* mimeType);
+
+G_END_DECLS
+
+#endif // WebKitSoupRequestGeneric_h
diff --git a/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp
new file mode 100644
index 000000000..8c484c7fe
--- /dev/null
+++ b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 library 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 library; 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 "WebSoupRequestManager.h"
+
+#include "DataReference.h"
+#include "MessageID.h"
+#include "WebKitSoupRequestGeneric.h"
+#include "WebProcess.h"
+#include "WebSoupRequestManagerProxyMessages.h"
+#include <WebCore/ErrorsGtk.h>
+#include <WebCore/ResourceHandle.h>
+#include <WebCore/ResourceRequest.h>
+#include <libsoup/soup-requester.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/text/CString.h>
+
+namespace WebKit {
+
+static uint64_t generateSoupRequestID()
+{
+ static uint64_t uniqueSoupRequestID = 1;
+ return uniqueSoupRequestID++;
+}
+
+WebSoupRequestManager::WebSoupRequestManager(WebProcess* process)
+ : m_process(process)
+ , m_schemes(adoptGRef(g_ptr_array_new_with_free_func(g_free)))
+{
+}
+
+WebSoupRequestManager::~WebSoupRequestManager()
+{
+}
+
+void WebSoupRequestManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebSoupRequestManagerMessage(connection, messageID, arguments);
+}
+
+void WebSoupRequestManager::registerURIScheme(const String& scheme)
+{
+ if (m_schemes->len)
+ g_ptr_array_remove_index_fast(m_schemes.get(), m_schemes->len - 1);
+ g_ptr_array_add(m_schemes.get(), g_strdup(scheme.utf8().data()));
+ g_ptr_array_add(m_schemes.get(), 0);
+
+ SoupSession* session = WebCore::ResourceHandle::defaultSession();
+ GRefPtr<SoupRequester> requester = SOUP_REQUESTER(soup_session_get_feature(session, SOUP_TYPE_REQUESTER));
+ if (requester)
+ soup_session_feature_remove_feature(SOUP_SESSION_FEATURE(requester.get()), WEBKIT_TYPE_SOUP_REQUEST_GENERIC);
+ else {
+ requester = adoptGRef(soup_requester_new());
+ soup_session_add_feature(session, SOUP_SESSION_FEATURE(requester.get()));
+ }
+ SoupRequestClass* genericRequestClass = static_cast<SoupRequestClass*>(g_type_class_ref(WEBKIT_TYPE_SOUP_REQUEST_GENERIC));
+ genericRequestClass->schemes = const_cast<const char**>(reinterpret_cast<char**>(m_schemes->pdata));
+ soup_session_feature_add_feature(SOUP_SESSION_FEATURE(requester.get()), WEBKIT_TYPE_SOUP_REQUEST_GENERIC);
+}
+
+void WebSoupRequestManager::handleURIRequest(const CoreIPC::DataReference& requestData, const String& mimeType, uint64_t requestID)
+{
+ GRefPtr<GSimpleAsyncResult> result = adoptGRef(m_requestMap.take(requestID));
+ ASSERT(result.get());
+
+ GRefPtr<WebKitSoupRequestGeneric> request = adoptGRef(WEBKIT_SOUP_REQUEST_GENERIC(g_async_result_get_source_object(G_ASYNC_RESULT(result.get()))));
+ if (requestData.size()) {
+ webkitSoupRequestGenericSetContentLength(request.get(), requestData.size());
+ webkitSoupRequestGenericSetContentType(request.get(), mimeType.utf8().data());
+ GInputStream* dataStream = g_memory_input_stream_new_from_data(requestData.data(), requestData.size(), 0);
+ g_simple_async_result_set_op_res_gpointer(result.get(), dataStream, g_object_unref);
+ } else {
+ GOwnPtr<char> uriString(soup_uri_to_string(soup_request_get_uri(SOUP_REQUEST(request.get())), FALSE));
+ WebCore::ResourceRequest resourceRequest(String::fromUTF8(uriString.get()));
+ WebCore::ResourceError resourceError(WebCore::cannotShowURLError(resourceRequest));
+ g_simple_async_result_set_error(result.get(), g_quark_from_string(resourceError.domain().utf8().data()),
+ resourceError.errorCode(), "%s", resourceError.localizedDescription().utf8().data());
+ }
+ g_simple_async_result_complete(result.get());
+}
+
+void WebSoupRequestManager::send(GSimpleAsyncResult* result)
+{
+ GRefPtr<WebKitSoupRequestGeneric> request = adoptGRef(WEBKIT_SOUP_REQUEST_GENERIC(g_async_result_get_source_object(G_ASYNC_RESULT(result))));
+ SoupURI* uri = soup_request_get_uri(SOUP_REQUEST(request.get()));
+ GOwnPtr<char> uriString(soup_uri_to_string(uri, FALSE));
+
+ uint64_t requestID = generateSoupRequestID();
+ m_requestMap.set(requestID, result);
+ m_process->connection()->send(Messages::WebSoupRequestManagerProxy::DidReceiveURIRequest(String::fromUTF8(uriString.get()), requestID), 0);
+}
+
+GInputStream* WebSoupRequestManager::finish(GSimpleAsyncResult* result)
+{
+ return G_INPUT_STREAM(g_object_ref(g_simple_async_result_get_op_res_gpointer(result)));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h
new file mode 100644
index 000000000..064316156
--- /dev/null
+++ b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 library 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 library; 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 WebSoupRequestManager_h
+#define WebSoupRequestManager_h
+
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+typedef struct _GInputStream GInputStream;
+typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+class DataReference;
+class MessageID;
+}
+
+namespace WebKit {
+
+class WebProcess;
+
+class WebSoupRequestManager {
+ WTF_MAKE_NONCOPYABLE(WebSoupRequestManager);
+public:
+ explicit WebSoupRequestManager(WebProcess*);
+ ~WebSoupRequestManager();
+
+ void send(GSimpleAsyncResult*);
+ GInputStream* finish(GSimpleAsyncResult*);
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+private:
+ void didReceiveWebSoupRequestManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ void registerURIScheme(const String& scheme);
+ void handleURIRequest(const CoreIPC::DataReference&, const String& mimeType, uint64_t requestID);
+
+ WebProcess* m_process;
+ GRefPtr<GPtrArray> m_schemes;
+ HashMap<uint64_t, GSimpleAsyncResult*> m_requestMap;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in
new file mode 100644
index 000000000..03fc96545
--- /dev/null
+++ b/Source/WebKit2/WebProcess/soup/WebSoupRequestManager.messages.in
@@ -0,0 +1,26 @@
+# 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.
+
+messages -> WebSoupRequestManager {
+ RegisterURIScheme(WTF::String uriScheme);
+ HandleURIRequest(CoreIPC::DataReference requestData, WTF::String mimeType, uint64_t requestID);
+}