diff options
Diffstat (limited to 'Source/WebKit2/WebProcess')
25 files changed, 204 insertions, 53 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index 14fccdc64..276f7d3cb 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -25,11 +25,12 @@ #include "config.h" #include "WKBundle.h" -#include "WKBundlePrivate.h" +#include "ImmutableArray.h" #include "InjectedBundle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" +#include "WKBundlePrivate.h" using namespace WebKit; @@ -248,7 +249,18 @@ uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef or void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes) { - return toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes); + toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes); +} + +void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin) +{ + toImpl(bundleRef)->resetApplicationCacheOriginQuota(toImpl(origin)->string()); +} + +WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundleRef) +{ + RefPtr<ImmutableArray> origins = toImpl(bundleRef)->originsWithApplicationCache(); + return toAPI(origins.release().leakRef()); } void WKBundleSetMinimumTimerInterval(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, double seconds) @@ -286,6 +298,12 @@ void WKBundleSetPageVisibilityState(WKBundleRef bundleRef, WKBundlePageRef pageR toImpl(bundleRef)->setPageVisibilityState(toImpl(pageRef), state, isInitialState); } +size_t WKBundleGetWorkerThreadCount(WKBundleRef) +{ + // Actually do not need argument here, keeping it however for consistency. + return InjectedBundle::workerThreadCount(); +} + void WKBundleSetUserStyleSheetLocation(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKStringRef location) { toImpl(bundleRef)->setUserStyleSheetLocation(toImpl(pageGroupRef), toImpl(location)->string()); @@ -306,3 +324,7 @@ uint64_t WKBundleGetWebNotificationID(WKBundleRef bundleRef, JSContextRef contex return toImpl(bundleRef)->webNotificationID(context, notification); } +void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundleRef, WKBundlePageRef pageRef, bool enabled) +{ + toImpl(bundleRef)->setTabKeyCyclesThroughElements(toImpl(pageRef), enabled); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index 4f86778bd..d32b5618c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -262,3 +262,12 @@ WKDataRef WKBundleFrameCopyWebArchiveFilteringSubframes(WKBundleFrameRef frameRe return 0; } + +bool WKBundleFrameCallShouldCloseOnWebView(WKBundleFrameRef frameRef) +{ + Frame* coreFrame = toImpl(frameRef)->coreFrame(); + if (!coreFrame) + return true; + + return coreFrame->loader()->shouldClose(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h index a786b2557..98722f856 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h @@ -52,6 +52,7 @@ WK_EXPORT void WKBundleFrameClearOpener(WKBundleFrameRef frame); WK_EXPORT bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frame); WK_EXPORT void WKBundleFrameSetTextDirection(WKBundleFrameRef frame, WKStringRef); +WK_EXPORT bool WKBundleFrameCallShouldCloseOnWebView(WKBundleFrameRef frame); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index 8bc7670cf..206e1e9c3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -236,6 +236,7 @@ typedef bool (*WKBundlePageShouldRubberBandInDirectionCallback)(WKBundlePageRef typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo); typedef WKBundlePageUIElementVisibility (*WKBundlePageMenuBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo); typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo); +typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo); struct WKBundlePageUIClient { int version; @@ -254,10 +255,13 @@ struct WKBundlePageUIClient { WKBundlePageStatusBarIsVisibleCallback statusBarIsVisible; WKBundlePageMenuBarIsVisibleCallback menuBarIsVisible; WKBundlePageToolbarsAreVisibleCallback toolbarsAreVisible; + + // Version 1. + WKBundlePageReachedAppCacheOriginQuotaCallback didReachApplicationCacheOriginQuota; }; typedef struct WKBundlePageUIClient WKBundlePageUIClient; -enum { kWKBundlePageUIClientCurrentVersion = 0 }; +enum { kWKBundlePageUIClientCurrentVersion = 1 }; // Editor client typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index e979791c9..3a1512aaf 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -99,6 +99,8 @@ WK_EXPORT void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundle, WKStri WK_EXPORT void WKBundleSetAppCacheMaximumSize(WKBundleRef bundle, uint64_t size); WK_EXPORT uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundle, WKStringRef origin); WK_EXPORT void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin, uint64_t bytes); +WK_EXPORT void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin); +WK_EXPORT WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundle); // Garbage collection API WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle); @@ -109,6 +111,10 @@ WK_EXPORT bool WKBundleIsProcessingUserGesture(WKBundleRef bundle); WK_EXPORT void WKBundleSetPageVisibilityState(WKBundleRef bundle, WKBundlePageRef page, int state, bool isInitialState); +WK_EXPORT size_t WKBundleGetWorkerThreadCount(WKBundleRef bundle); + +WK_EXPORT void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundle, WKBundlePageRef page, bool enabled); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index cd0634906..a7de64e8a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -67,6 +67,7 @@ #include <WebCore/SecurityPolicy.h> #include <WebCore/Settings.h> #include <WebCore/UserGestureIndicator.h> +#include <WebCore/WorkerThread.h> #include <wtf/OwnArrayPtr.h> #include <wtf/PassOwnArrayPtr.h> @@ -358,6 +359,26 @@ void InjectedBundle::setApplicationCacheOriginQuota(const String& originString, cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), bytes); } +void InjectedBundle::resetApplicationCacheOriginQuota(const String& originString) +{ + RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString); + cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), cacheStorage().defaultOriginQuota()); +} + +PassRefPtr<ImmutableArray> InjectedBundle::originsWithApplicationCache() +{ + HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash> origins; + cacheStorage().getOriginsWithCache(origins); + Vector< RefPtr<APIObject> > originsVector; + + HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator it = origins.begin(); + HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator end = origins.end(); + for ( ; it != end; ++it) + originsVector.append(WebString::create((*it)->databaseIdentifier())); + + return ImmutableArray::adopt(originsVector); +} + int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels) { Frame* coreFrame = frame ? frame->coreFrame() : 0; @@ -570,6 +591,15 @@ void InjectedBundle::setPageVisibilityState(WebPage* page, int state, bool isIni #endif } +size_t InjectedBundle::workerThreadCount() +{ +#if ENABLE(WORKERS) + return WebCore::WorkerThread::workerThreadCount(); +#else + return 0; +#endif +} + void InjectedBundle::setUserStyleSheetLocation(WebPageGroupProxy* pageGroup, const String& location) { const HashSet<Page*>& pages = PageGroup::pageGroup(pageGroup->identifier())->pages(); @@ -616,4 +646,9 @@ uint64_t InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef js #endif } +void InjectedBundle::setTabKeyCyclesThroughElements(WebPage* page, bool enabled) +{ + page->corePage()->setTabKeyCyclesThroughElements(enabled); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h index 6e40013df..404a50593 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h @@ -150,6 +150,8 @@ public: void setAppCacheMaximumSize(uint64_t); uint64_t appCacheUsageForOrigin(const String& origin); void setApplicationCacheOriginQuota(const String& origin, uint64_t); + void resetApplicationCacheOriginQuota(const String& origin); + PassRefPtr<ImmutableArray> originsWithApplicationCache(); // Garbage collection API void garbageCollectJavaScriptObjects(); @@ -171,6 +173,10 @@ public: void setPageVisibilityState(WebPage*, int state, bool isInitialState); + static size_t workerThreadCount(); + + void setTabKeyCyclesThroughElements(WebPage*, bool enabled); + private: explicit InjectedBundle(const String&); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp index 29c70dfb4..428135481 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp @@ -91,7 +91,7 @@ InjectedBundleNavigationAction::InjectedBundleNavigationAction(WebFrame* frame, , m_mouseButton(WebMouseEvent::NoButton) { if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) { - m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation())); + m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false)); m_mouseButton = mouseButtonForMouseEvent(mouseEvent); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp index b8c9c6206..2ef9ca76f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp @@ -28,8 +28,9 @@ #include "InjectedBundleHitTestResult.h" #include "WKAPICast.h" -#include "WebGraphicsContext.h" #include "WKBundleAPICast.h" +#include "WebGraphicsContext.h" +#include "WebSecurityOrigin.h" #include <wtf/text/WTFString.h> using namespace WebCore; @@ -146,4 +147,12 @@ WKBundlePageUIElementVisibility InjectedBundlePageUIClient::toolbarsAreVisible(W return m_client.toolbarsAreVisible(toAPI(page), m_client.clientInfo); } +void InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* page, WebSecurityOrigin* origin, int64_t totalBytesNeeded) +{ + if (!m_client.didReachApplicationCacheOriginQuota) + return; + + m_client.didReachApplicationCacheOriginQuota(toAPI(page), toAPI(origin), totalBytesNeeded, m_client.clientInfo); +} + } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h index de2928aa5..b8a48271f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h @@ -42,6 +42,7 @@ namespace WebKit { class APIObject; class WebFrame; class WebPage; +class WebSecurityOrigin; class InjectedBundlePageUIClient : public APIClient<WKBundlePageUIClient, kWKBundlePageUIClientCurrentVersion> { public: @@ -64,6 +65,8 @@ public: WKBundlePageUIElementVisibility statusBarIsVisible(WebPage*); WKBundlePageUIElementVisibility menuBarIsVisible(WebPage*); WKBundlePageUIElementVisibility toolbarsAreVisible(WebPage*); + + void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded); }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index 75838ec80..3a428e63a 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -688,14 +688,20 @@ static void NPN_ReleaseObject(NPObject *npObject) static bool NPN_Invoke(NPP npp, NPObject *npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) { + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + PluginDestructionProtector protector(plugin.get()); + if (npObject->_class->invoke) return npObject->_class->invoke(npObject, methodName, arguments, argumentCount, result); return false; } -static bool NPN_InvokeDefault(NPP, NPObject *npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) +static bool NPN_InvokeDefault(NPP npp, NPObject *npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) { + RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp); + PluginDestructionProtector protector(plugin.get()); + if (npObject->_class->invokeDefault) return npObject->_class->invokeDefault(npObject, arguments, argumentCount, result); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index e37d75269..01238cbc1 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -375,21 +375,15 @@ uint32_t NetscapePlugin::scheduleTimer(unsigned interval, bool repeat, void (*ti // FIXME: Based on the plug-in visibility, figure out if we should throttle the timer, or if we should start it at all. timer->start(); - m_timers.set(timerID, timer.leakPtr()); + m_timers.set(timerID, timer.release()); return timerID; } void NetscapePlugin::unscheduleTimer(unsigned timerID) { - TimerMap::iterator it = m_timers.find(timerID); - if (it == m_timers.end()) - return; - - OwnPtr<Timer> timer = adoptPtr(it->second); - m_timers.remove(it); - - timer->stop(); + if (OwnPtr<Timer> timer = m_timers.take(timerID)) + timer->stop(); } double NetscapePlugin::contentsScaleFactor() @@ -687,7 +681,6 @@ void NetscapePlugin::destroy() platformDestroy(); - deleteAllValues(m_timers); m_timers.clear(); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index f0d948b0e..2c290c76b 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -308,7 +308,7 @@ private: WebCore::RunLoop::Timer<Timer> m_timer; }; - typedef HashMap<unsigned, Timer*> TimerMap; + typedef HashMap<unsigned, OwnPtr<Timer> > TimerMap; TimerMap m_timers; unsigned m_nextTimerID; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index c7fc9a7b7..4fb65bec3 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -45,6 +45,7 @@ #include "WebPreferencesStore.h" #include "WebProcess.h" #include "WebSearchPopupMenu.h" +#include "WebSecurityOrigin.h" #include <WebCore/AXObjectCache.h> #include <WebCore/ColorChooser.h> #include <WebCore/DatabaseTracker.h> @@ -549,9 +550,10 @@ void WebChromeClient::reachedMaxAppCacheSize(int64_t) notImplemented(); } -void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t) +void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, int64_t totalBytesNeeded) { - notImplemented(); + RefPtr<WebSecurityOrigin> webSecurityOrigin = WebSecurityOrigin::createFromString(origin->toString()); + m_page->injectedBundleUIClient().didReachApplicationCacheOriginQuota(m_page, webSecurityOrigin.get(), totalBytesNeeded); } #if ENABLE(DASHBOARD_SUPPORT) diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp index 2411051f6..0d2bd4d3f 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp @@ -78,6 +78,7 @@ LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage) , m_shouldSyncFrame(false) , m_shouldSyncRootLayer(true) , m_layerFlushTimer(this, &LayerTreeCoordinator::layerFlushTimerFired) + , m_releaseInactiveAtlasesTimer(this, &LayerTreeCoordinator::releaseInactiveAtlasesTimerFired) , m_layerFlushSchedulingEnabled(true) , m_forceRepaintAsyncCallbackID(0) { @@ -634,8 +635,42 @@ PassOwnPtr<WebCore::GraphicsContext> LayerTreeCoordinator::beginContentUpdate(co static const int ScratchBufferDimension = 1024; // Should be a power of two. m_updateAtlases.append(adoptPtr(new UpdateAtlas(ScratchBufferDimension, flags))); + scheduleReleaseInactiveAtlases(); return m_updateAtlases.last()->beginPaintingOnAvailableBuffer(handle, size, offset); } +const double ReleaseInactiveAtlasesTimerInterval = 0.5; + +void LayerTreeCoordinator::scheduleReleaseInactiveAtlases() +{ + if (!m_releaseInactiveAtlasesTimer.isActive()) + m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval); +} + +void LayerTreeCoordinator::releaseInactiveAtlasesTimerFired(Timer<LayerTreeCoordinator>*) +{ + // We always want to keep one atlas for non-composited content. + OwnPtr<UpdateAtlas> atlasToKeepAnyway; + bool foundActiveAtlasForNonCompositedContent = false; + for (int i = m_updateAtlases.size() - 1; i >= 0; --i) { + UpdateAtlas* atlas = m_updateAtlases[i].get(); + if (!atlas->isInUse()) + atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval); + bool usableForNonCompositedContent = atlas->flags() == ShareableBitmap::NoFlags; + if (atlas->isInactive()) { + if (!foundActiveAtlasForNonCompositedContent && !atlasToKeepAnyway && usableForNonCompositedContent) + atlasToKeepAnyway = m_updateAtlases[i].release(); + m_updateAtlases.remove(i); + } else if (usableForNonCompositedContent) + foundActiveAtlasForNonCompositedContent = true; + } + + if (!foundActiveAtlasForNonCompositedContent && atlasToKeepAnyway) + m_updateAtlases.append(atlasToKeepAnyway.release()); + + if (m_updateAtlases.size() <= 1) + m_releaseInactiveAtlasesTimer.stop(); +} + } // namespace WebKit #endif // USE(COORDINATED_GRAPHICS) diff --git a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h index c8ef54a68..73b84e524 100644 --- a/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h +++ b/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h @@ -113,6 +113,11 @@ private: void didPerformScheduledLayerFlush(); void syncDisplayState(); + void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*); + + void scheduleReleaseInactiveAtlases(); + void releaseInactiveAtlasesTimerFired(WebCore::Timer<LayerTreeCoordinator>*); + OwnPtr<WebCore::GraphicsLayer> m_rootLayer; // The layer which contains all non-composited content. @@ -137,8 +142,8 @@ private: LayerTreeContext m_layerTreeContext; bool m_shouldSyncFrame; bool m_shouldSyncRootLayer; - void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*); WebCore::Timer<LayerTreeCoordinator> m_layerFlushTimer; + WebCore::Timer<LayerTreeCoordinator> m_releaseInactiveAtlasesTimer; bool m_layerFlushSchedulingEnabled; uint64_t m_forceRepaintAsyncCallbackID; }; diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h index 759e675ad..9c7212a9b 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingArea.h @@ -49,6 +49,7 @@ struct ColorSpaceData; class LayerTreeHost; class WebPage; struct WebPageCreationParameters; +struct WebPreferencesStore; #if PLATFORM(WIN) struct WindowGeometry; @@ -83,7 +84,7 @@ public: virtual void pageCustomRepresentationChanged() { } virtual void setPaintingEnabled(bool) { } - virtual void updatePreferences() { } + virtual void updatePreferences(const WebPreferencesStore&) { } #if USE(ACCELERATED_COMPOSITING) virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0; diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp index eefd1bb88..6548a25ed 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp @@ -259,6 +259,18 @@ void DrawingAreaImpl::setPaintingEnabled(bool paintingEnabled) m_isPaintingEnabled = paintingEnabled; } +void DrawingAreaImpl::updatePreferences(const WebPreferencesStore& store) +{ + // <rdar://problem/10697417>: It is necessary to force compositing when accelerate drawing + // is enabled on Mac so that scrollbars are always in their own layers. +#if PLATFORM(MAC) + if (m_webPage->corePage()->settings()->acceleratedDrawingEnabled()) + m_webPage->corePage()->settings()->setForceCompositingMode(LayerTreeHost::supportsAcceleratedCompositing()); + else +#endif + m_webPage->corePage()->settings()->setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()) && LayerTreeHost::supportsAcceleratedCompositing()); +} + void DrawingAreaImpl::layerHostDidFlushLayers() { ASSERT(m_layerTreeHost); diff --git a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h index 0174a5d6e..ffe3112c0 100644 --- a/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h +++ b/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.h @@ -66,6 +66,7 @@ private: virtual bool pageOverlayShouldApplyFadeWhenPainting() const; virtual void setPaintingEnabled(bool); + virtual void updatePreferences(const WebPreferencesStore&) OVERRIDE; virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); virtual void scheduleCompositingLayerSync(); diff --git a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp index 10a35d885..27500635d 100644 --- a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp +++ b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp @@ -32,6 +32,7 @@ namespace WebKit { UpdateAtlas::UpdateAtlas(int dimension, ShareableBitmap::Flags flags) : m_flags(flags) + , m_inactivityInSeconds(0) { IntSize size = nextPowerOfTwo(IntSize(dimension, dimension)); m_surface = ShareableSurface::create(size, flags, ShareableSurface::SupportsGraphicsSurface); @@ -48,11 +49,11 @@ void UpdateAtlas::buildLayoutIfNeeded() void UpdateAtlas::didSwapBuffers() { m_areaAllocator.clear(); - buildLayoutIfNeeded(); } PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(ShareableSurface::Handle& handle, const WebCore::IntSize& size, IntPoint& offset) { + m_inactivityInSeconds = 0; buildLayoutIfNeeded(); IntRect rect = m_areaAllocator->allocate(size); diff --git a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h index 774ccfdd3..00e850b83 100644 --- a/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h +++ b/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h @@ -44,6 +44,18 @@ public: void didSwapBuffers(); ShareableBitmap::Flags flags() const { return m_flags; } + void addTimeInactive(double seconds) + { + ASSERT(!isInUse()); + m_inactivityInSeconds += seconds; + } + bool isInactive() const + { + const double inactiveSecondsTolerance = 3; + return m_inactivityInSeconds > inactiveSecondsTolerance; + } + bool isInUse() const { return m_areaAllocator; } + private: void buildLayoutIfNeeded(); @@ -51,6 +63,7 @@ private: OwnPtr<GeneralAreaAllocator> m_areaAllocator; ShareableBitmap::Flags m_flags; RefPtr<ShareableSurface> m_surface; + double m_inactivityInSeconds; }; } diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index eb8067079..915140f8d 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -307,17 +307,16 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters) m_page->setCanStartMedia(false); - updatePreferences(parameters.store); - m_pageGroup = WebProcess::shared().webPageGroup(parameters.pageGroupData); m_page->setGroupName(m_pageGroup->identifier()); m_page->setDeviceScaleFactor(parameters.deviceScaleFactor); - platformInitialize(); - m_drawingArea = DrawingArea::create(this, parameters); m_drawingArea->setPaintingEnabled(false); + updatePreferences(parameters.store); + platformInitialize(); + m_mainFrame = WebFrame::createMainFrame(this); setUseFixedLayout(parameters.useFixedLayout); @@ -1315,7 +1314,7 @@ static bool isContextClick(const PlatformMouseEvent& event) static bool handleContextMenuEvent(const PlatformMouseEvent& platformMouseEvent, WebPage* page) { IntPoint point = page->corePage()->mainFrame()->view()->windowToContents(platformMouseEvent.position()); - HitTestResult result = page->corePage()->mainFrame()->eventHandler()->hitTestResultAtPoint(point); + HitTestResult result = page->corePage()->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false); Frame* frame = page->corePage()->mainFrame(); if (result.innerNonSharedNode()) @@ -1566,7 +1565,7 @@ void WebPage::highlightPotentialActivation(const IntPoint& point, const IntSize& return; #else - HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent); + HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true); adjustedNode = result.innerNode(); #endif // Find the node to highlight. This is not the same as the node responding the tap gesture, because many @@ -2081,15 +2080,6 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) #endif settings->setInteractiveFormValidationEnabled(store.getBoolValueForKey(WebPreferencesKey::interactiveFormValidationEnabledKey())); - // <rdar://problem/10697417>: It is necessary to force compositing when accelerate drawing - // is enabled on Mac so that scrollbars are always in their own layers. -#if PLATFORM(MAC) - if (settings->acceleratedDrawingEnabled()) - settings->setForceCompositingMode(LayerTreeHost::supportsAcceleratedCompositing()); - else -#endif - settings->setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()) && LayerTreeHost::supportsAcceleratedCompositing()); - #if ENABLE(SQL_DATABASE) AbstractDatabase::setIsAvailable(store.getBoolValueForKey(WebPreferencesKey::databasesEnabledKey())); #endif @@ -2134,7 +2124,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store) platformPreferencesDidChange(store); if (m_drawingArea) - m_drawingArea->updatePreferences(); + m_drawingArea->updatePreferences(store); } #if ENABLE(INSPECTOR) @@ -2736,7 +2726,7 @@ void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point, const Web { UNUSED_PARAM(area); Frame* mainframe = m_mainFrame->coreFrame(); - HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping); + HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true); Node* node = result.innerNode(); diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h index 4a4e06709..22599edad 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h @@ -64,7 +64,7 @@ private: virtual void didInstallPageOverlay() OVERRIDE; virtual void didUninstallPageOverlay() OVERRIDE; virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) OVERRIDE; - virtual void updatePreferences() OVERRIDE; + virtual void updatePreferences(const WebPreferencesStore&) OVERRIDE; virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&) OVERRIDE; diff --git a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm index 65660b319..6c723a956 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm @@ -71,11 +71,10 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c , m_layerFlushScheduler(this) , m_isPaintingSuspended(!parameters.isVisible) { - Page* page = webPage->corePage(); + Page* page = m_webPage->corePage(); - // FIXME: It's weird that we're mucking around with the settings here. - page->settings()->setForceCompositingMode(true); page->settings()->setScrollingCoordinatorEnabled(true); + page->settings()->setForceCompositingMode(true); WebProcess::shared().eventDispatcher().addScrollingTreeForPage(webPage); @@ -92,8 +91,6 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c LayerTreeContext layerTreeContext; layerTreeContext.contextID = m_layerHostingContext->contextID(); m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(0, layerTreeContext)); - - updatePreferences(); } TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea() @@ -206,8 +203,11 @@ void TiledCoreAnimationDrawingArea::setPageOverlayNeedsDisplay(const IntRect& re scheduleCompositingLayerSync(); } -void TiledCoreAnimationDrawingArea::updatePreferences() +void TiledCoreAnimationDrawingArea::updatePreferences(const WebPreferencesStore&) { + bool scrollingPerformanceLoggingEnabled = m_webPage->scrollingPerformanceLoggingEnabled(); + ScrollingThread::dispatch(bind(&ScrollingTree::setScrollingPerformanceLoggingEnabled, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), scrollingPerformanceLoggingEnabled)); + bool showDebugBorders = m_webPage->corePage()->settings()->showDebugBorders(); if (showDebugBorders == !!m_debugInfoLayer) @@ -221,10 +221,7 @@ void TiledCoreAnimationDrawingArea::updatePreferences() m_debugInfoLayer = nullptr; } - bool scrollingPerformanceLoggingEnabled = m_webPage->scrollingPerformanceLoggingEnabled(); - ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer)); - ScrollingThread::dispatch(bind(&ScrollingTree::setScrollingPerformanceLoggingEnabled, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), scrollingPerformanceLoggingEnabled)); } void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& functionRef) diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm index 359f35a5f..c2f016537 100644 --- a/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm +++ b/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm @@ -375,7 +375,7 @@ void WebPage::characterIndexForPoint(IntPoint point, uint64_t& index) if (!frame) return; - HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(point); + HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(point, false); frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController()->focusedOrMainFrame(); RefPtr<Range> range = frame->rangeForPoint(result.roundedPoint()); @@ -464,7 +464,7 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint) // Find the frame the point is over. IntPoint point = roundedIntPoint(floatPoint); - HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(point)); + HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(point), false); frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document()->frame() : m_page->focusController()->focusedOrMainFrame(); IntPoint translatedPoint = frame->view()->windowToContents(point); @@ -727,7 +727,7 @@ void WebPage::shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent& event, return; #if ENABLE(DRAG_SUPPORT) - HitTestResult hitResult = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(event.position()), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent); + HitTestResult hitResult = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(event.position()), true); if (hitResult.isSelected()) result = frame->eventHandler()->eventMayStartDrag(platform(event)); #endif @@ -740,7 +740,7 @@ void WebPage::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& ev if (!frame) return; - HitTestResult hitResult = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(event.position()), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowShadowContent); + HitTestResult hitResult = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(event.position()), true); frame->eventHandler()->setActivationEventNumber(eventNumber); #if ENABLE(DRAG_SUPPORT) if (hitResult.isSelected()) |
