Modified: trunk/Source/WebKit2/ChangeLog (147592 => 147593)
--- trunk/Source/WebKit2/ChangeLog 2013-04-03 22:54:51 UTC (rev 147592)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-03 22:54:56 UTC (rev 147593)
@@ -1,5 +1,16 @@
2013-04-02 Mark Rowe <mr...@apple.com>
+ <http://webkit.org/b/113898> Eliminate some code duplication by introducing an array of handlers to register / unregister.
+
+ Reviewed by Antti Koivisto.
+
+ * UIProcess/mac/WebContextMac.mm:
+ (OcclusionNotificationHandler): Structure containing the notification name, type and handler.
+ (WebKit::registerOcclusionNotificationHandlers): Register all of the handlers in the array.
+ (WebKit::unregisterOcclusionNotificationHandlers): Unregister all of the handlers in the array.
+
+2013-04-02 Mark Rowe <mr...@apple.com>
+
Enable process suppression when no windows in the application have drawn recently.
<http://webkit.org/b/113854> / <rdar://problem/13540351>
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (147592 => 147593)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2013-04-03 22:54:51 UTC (rev 147592)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2013-04-03 22:54:56 UTC (rev 147593)
@@ -146,55 +146,40 @@
applicationOcclusionStateChanged();
}
+struct OcclusionNotificationHandler {
+ WKOcclusionNotificationType notificationType;
+ WKOcclusionNotificationHandler handler;
+ const char *name;
+};
+
+static const OcclusionNotificationHandler occlusionNotificationHandlers[] = {
+ { WKOcclusionNotificationTypeApplicationBecameVisible, applicationBecameVisible, "Application Became Visible" },
+ { WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameOccluded, "Application Became Occluded" },
+ { WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted, "Application Window Modifications Started" },
+ { WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped, "Application Window Modifications Stopped" },
+};
+
#endif
static void registerOcclusionNotificationHandlers()
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameVisible, applicationBecameVisible)) {
- WTFLogAlways("Registration of \"Application Became Visible\" notification handler failed.\n");
- return;
+ for (const OcclusionNotificationHandler& occlusionNotificationHandler : occlusionNotificationHandlers) {
+ bool result = WKRegisterOcclusionNotificationHandler(occlusionNotificationHandler.notificationType, occlusionNotificationHandler.handler);
+ UNUSED_PARAM(result);
+ ASSERT_WITH_MESSAGE(result, "Registration of \"%s\" notification handler failed.\n", occlusionNotificationHandler.name);
}
-
- if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameOccluded)) {
- WTFLogAlways("Registration of \"Application Became Occluded\" notification handler failed.\n");
- return;
- }
-
- if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted)) {
- WTFLogAlways("Registration of \"Application Window Modifications Started\" notification handler failed.\n");
- return;
- }
-
- if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped)) {
- WTFLogAlways("Registration of \"Application Window Modifications Stopped\" notification handler failed.\n");
- return;
- }
#endif
}
static void unregisterOcclusionNotificationHandlers()
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameOccluded)) {
- WTFLogAlways("Unregistration of \"Application Became Occluded\" notification handler failed.\n");
- return;
+ for (const OcclusionNotificationHandler& occlusionNotificationHandler : occlusionNotificationHandlers) {
+ bool result = WKUnregisterOcclusionNotificationHandler(occlusionNotificationHandler.notificationType, occlusionNotificationHandler.handler);
+ UNUSED_PARAM(result);
+ ASSERT_WITH_MESSAGE(result, "Unregistration of \"%s\" notification handler failed.\n", occlusionNotificationHandler.name);
}
-
- if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameVisible)) {
- WTFLogAlways("Unregistration of \"Application Became Visible\" notification handler failed.\n");
- return;
- }
-
- if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted)) {
- WTFLogAlways("Unregistration of \"Application Window Modifications Started\" notification handler failed.\n");
- return;
- }
-
- if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped)) {
- WTFLogAlways("Unregistration of \"Application Window Modifications Stopped\" notification handler failed.\n");
- return;
- }
#endif
}