Diff
Modified: trunk/Source/WebCore/ChangeLog (95512 => 95513)
--- trunk/Source/WebCore/ChangeLog 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebCore/ChangeLog 2011-09-20 04:14:55 UTC (rev 95513)
@@ -1,3 +1,39 @@
+2011-09-19 Mark Rowe <mr...@apple.com>
+
+ <http://webkit.org/b/68421> Stop calling UpdateSystemActivity in places where we hold power assertions that achieve the same effect
+
+ On SnowLeopard and newer it's not necessary to call UpdateSystemActivity to prevent the screensaver from kicking
+ in as the NoDisplaySleep assertion now has that effect. It's also not necessary to hold both a NoDisplaySleep and
+ a NoIdleSleep assertion as the latter is implied by the former.
+
+ Since there were multiple copies of the same code to disable display sleep spread across WebCore, WebKit and WebKit2
+ this patch takes the approach of moving this functionality to a new DisplaySleepDisabler class that lives in WebCore.
+ A class is used as it makes it easier to reason about the lifetime of the assertions and to ensure that the assertions will
+ always be released when their owning objects go away.
+
+ Reviewed by Dan Bernstein.
+
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/mac/DisplaySleepDisabler.cpp:
+ (WebCore::DisplaySleepDisabler::DisplaySleepDisabler): Register for the NoDisplaySleep assertion, and start our
+ system activity timer when on Leopard.
+ (WebCore::DisplaySleepDisabler::~DisplaySleepDisabler): Unregister for the assertion.
+ (WebCore::DisplaySleepDisabler::systemActivityTimerFired): Call UpdateSystemActivity to prevent the screensaver from
+ triggering on Leopard.
+ * platform/mac/DisplaySleepDisabler.h:
+ (WebCore::DisplaySleepDisabler::create):
+ * platform/mac/WebVideoFullscreenController.h:
+ * platform/mac/WebVideoFullscreenController.mm:
+ (-[WebVideoFullscreenController dealloc]):
+ (-[WebVideoFullscreenController setupVideoOverlay:]): Remove the now-unnecessary explicit use of the WebCore namespace.
+ (-[WebVideoFullscreenController mediaElement]): Ditto.
+ (-[WebVideoFullscreenController setMediaElement:]): Ditto.
+ (-[WebVideoFullscreenController windowDidExitFullscreen]): Ditto.
+ (-[WebVideoFullscreenController updatePowerAssertions]): Create a DisplaySleepDisabler instance when transitioning from permitting
+ display sleep to disabling display sleep. Clear out our reference when sleep should be permitted, destroying any
+ disabler that we own.
+
2011-09-19 Ryosuke Niwa <rn...@webkit.org>
Hit testing on margins of body and head elements doesn't recur
Modified: trunk/Source/WebCore/WebCore.exp.in (95512 => 95513)
--- trunk/Source/WebCore/WebCore.exp.in 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-09-20 04:14:55 UTC (rev 95513)
@@ -549,6 +549,8 @@
__ZN7WebCore19TextResourceDecoderC1ERKN3WTF6StringERKNS_12TextEncodingEb
__ZN7WebCore19TextResourceDecoderD1Ev
__ZN7WebCore19applicationIsSafariEv
+__ZN7WebCore20DisplaySleepDisablerC1EPKc
+__ZN7WebCore20DisplaySleepDisablerD1Ev
__ZN7WebCore20NodeRenderingContextC1EPNS_4NodeE
__ZN7WebCore20NodeRenderingContextD1Ev
__ZN7WebCore20RenderEmbeddedObject30setShowsCrashedPluginIndicatorEv
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (95512 => 95513)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-09-20 04:14:55 UTC (rev 95513)
@@ -1551,6 +1551,8 @@
5D87BB8311E3ED8600702B6F /* ExportFileGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D87BB8211E3ED8600702B6F /* ExportFileGenerator.cpp */; };
5D88EE9111407FD300BC3ABC /* DOMSVGFEMorphologyElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 84224189107E786F00766A87 /* DOMSVGFEMorphologyElement.h */; };
5D88EE9211407FF400BC3ABC /* DOMSVGFEMorphologyElementInternal.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 8422418B107E786F00766A87 /* DOMSVGFEMorphologyElementInternal.h */; };
+ 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */; };
+ 5D8C4DC01428222C0026CE72 /* DisplaySleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */; settings = {ATTRIBUTES = (Private, ); }; };
5D925B670F64D4DD00B847F0 /* ScrollBehavior.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */; };
5D925B680F64D4DD00B847F0 /* ScrollBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D925B660F64D4DD00B847F0 /* ScrollBehavior.h */; settings = {ATTRIBUTES = (Private, ); }; };
5DA5E0FC102B953800088CF9 /* JSWebSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DA5E0FA102B953800088CF9 /* JSWebSocket.cpp */; };
@@ -8209,6 +8211,8 @@
5D4B8C5211E52C8B00BBB62F /* WebCore.exp.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebCore.exp.in; sourceTree = "<group>"; };
5D87BB4F11E3EAEB00702B6F /* WebCoreExportFileGenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = WebCoreExportFileGenerator; sourceTree = BUILT_PRODUCTS_DIR; };
5D87BB8211E3ED8600702B6F /* ExportFileGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExportFileGenerator.cpp; path = DerivedSources/WebCore/ExportFileGenerator.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplaySleepDisabler.cpp; sourceTree = "<group>"; };
+ 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplaySleepDisabler.h; sourceTree = "<group>"; };
5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollBehavior.cpp; sourceTree = "<group>"; };
5D925B660F64D4DD00B847F0 /* ScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBehavior.h; sourceTree = "<group>"; };
5DA5E0FA102B953800088CF9 /* JSWebSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebSocket.cpp; sourceTree = "<group>"; };
@@ -14528,7 +14532,6 @@
6582A14809999D6C00BEEB6D /* mac */ = {
isa = PBXGroup;
children = (
- 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */,
51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */,
65A640F00533BB1F0085E777 /* BlockExceptions.h */,
65F80697054D9F86008BF776 /* BlockExceptions.mm */,
@@ -14538,6 +14541,8 @@
93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */,
9352087609BD453400F2038D /* CookieJar.mm */,
F58784F002DE375901EA4122 /* CursorMac.mm */,
+ 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */,
+ 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */,
A795463D0B5C4C80007B438F /* DragDataMac.mm */,
A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */,
5DC87EEF11716DF2001C0E6D /* EmptyProtocolDefinitions.h */,
@@ -14556,6 +14561,7 @@
1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */,
BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */,
+ 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */,
A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
4B2709810AF2E5E00065127F /* PasteboardMac.mm */,
935C476F09AC4D7300A6AAB4 /* PlatformMouseEventMac.mm */,
@@ -20462,6 +20468,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 5D8C4DC01428222C0026CE72 /* DisplaySleepDisabler.h in Headers */,
B5B5DC6A119BB3D5002A8790 /* AbstractDatabase.h in Headers */,
41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
29A8122E0FBB9C1D00510293 /* AccessibilityARIAGridCell.h in Headers */,
@@ -26310,6 +26317,7 @@
978AD67414130A8D00C7CAE3 /* HTMLSpanElement.cpp in Sources */,
9752D38D1413104B003305BD /* JSHTMLSpanElement.cpp in Sources */,
0FE71405142170B800DB33BA /* ScrollbarThemeMock.cpp in Sources */,
+ 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Copied: trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.cpp (from rev 95512, trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h) (0 => 95513)
--- trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.cpp 2011-09-20 04:14:55 UTC (rev 95513)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplaySleepDisabler.h"
+
+#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <wtf/RetainPtr.h>
+
+#ifdef BUILDING_ON_LEOPARD
+#include <wtf/UnusedParam.h>
+#endif
+
+namespace WebCore {
+
+static const double systemActivityInterval = 1;
+
+DisplaySleepDisabler::DisplaySleepDisabler(const char* reason)
+ : m_disableDisplaySleepAssertion(0)
+#ifdef BUILDING_ON_LEOPARD
+ , m_systemActivityTimer(this, &DisplaySleepDisabler::systemActivityTimerFired)
+#endif
+{
+#ifndef BUILDING_ON_LEOPARD
+ RetainPtr<CFStringRef> reasonCF(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, reason, kCFStringEncodingUTF8));
+ IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonCF.get(), &m_disableDisplaySleepAssertion);
+#else
+ UNUSED_PARAM(reason);
+ IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);
+ m_systemActivityTimer.startRepeating(systemActivityInterval);
+#endif
+}
+
+DisplaySleepDisabler::~DisplaySleepDisabler()
+{
+ IOPMAssertionRelease(m_disableDisplaySleepAssertion);
+}
+
+#ifdef BUILDING_ON_LEOPARD
+void DisplaySleepDisabler::systemActivityTimerFired(Timer<DisplaySleepDisabler>*)
+{
+ UpdateSystemActivity(OverallAct);
+}
+#endif
+
+}
Copied: trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.h (from rev 95512, trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h) (0 => 95513)
--- trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.h (rev 0)
+++ trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.h 2011-09-20 04:14:55 UTC (rev 95513)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DisplaySleepDisabler_h
+#define DisplaySleepDisabler_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+
+#ifdef BUILDNG_ON_LEOPARD
+#include "Timer.h"
+#endif
+
+namespace WebCore {
+
+class DisplaySleepDisabler {
+ WTF_MAKE_NONCOPYABLE(DisplaySleepDisabler);
+public:
+ static PassOwnPtr<DisplaySleepDisabler> create(const char* reason) { return adoptPtr(new DisplaySleepDisabler(reason)); }
+ ~DisplaySleepDisabler();
+
+private:
+ DisplaySleepDisabler(const char* reason);
+
+#ifdef BUILDNG_ON_LEOPARD
+ void systemActivityTimerFired(Timer<DisplaySleepDisabler>*);
+#endif
+
+ uint32_t m_disableDisplaySleepAssertion;
+#ifdef BUILDNG_ON_LEOPARD
+ Timer<DisplaySleepDisabler> m_systemActivityTimer;
+#endif
+};
+
+}
+
+#endif // DisplaySleepDisabler_h
Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.h (95512 => 95513)
--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.h 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.h 2011-09-20 04:14:55 UTC (rev 95513)
@@ -27,10 +27,11 @@
#import <AppKit/NSWindowController.h>
#import <AppKit/NSScreen.h>
-#import <Foundation/NSTimer.h>
+#import <wtf/OwnPtr.h>
#import <wtf/RefPtr.h>
namespace WebCore {
+ class DisplaySleepDisabler;
class HTMLMediaElement;
}
@@ -51,9 +52,8 @@
BOOL _isEndingFullscreen;
BOOL _forceDisableAnimation;
- uint32_t _idleDisplaySleepAssertion;
- uint32_t _idleSystemSleepAssertion;
- NSTimer *_tickleTimer;
+
+ OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler;
}
- (id <WebVideoFullscreenControllerDelegate>)delegate;
Modified: trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm (95512 => 95513)
--- trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm 2011-09-20 04:14:55 UTC (rev 95513)
@@ -32,8 +32,8 @@
#import "WebVideoFullscreenHUDWindowController.h"
#import "WebWindowAnimation.h"
#import <Carbon/Carbon.h>
-#import <IOKit/pwr_mgt/IOPMLib.h>
#import <QTKit/QTKit.h>
+#import <WebCore/DisplaySleepDisabler.h>
#import <WebCore/HTMLMediaElement.h>
#import <WebCore/SoftLinking.h>
#import <objc/objc-runtime.h>
@@ -43,13 +43,14 @@
#import <WebCore/GStreamerGWorld.h>
#endif
+using namespace WebCore;
+
SOFT_LINK_FRAMEWORK(QTKit)
SOFT_LINK_CLASS(QTKit, QTMovieLayer)
SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *)
#define QTMovieRateDidChangeNotification getQTMovieRateDidChangeNotification()
-static const NSTimeInterval tickleTimerInterval = 1.0;
@interface WebVideoFullscreenWindow : NSWindow
#ifndef BUILDING_ON_LEOPARD
@@ -89,9 +90,6 @@
{
ASSERT(!_backgroundFullscreenWindow);
ASSERT(!_fadeAnimation);
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@@ -105,15 +103,15 @@
{
WebVideoFullscreenWindow *window = [self fullscreenWindow];
#if USE(GSTREAMER)
- if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::GStreamerGWorldType) {
- WebCore::GStreamerGWorld* gstGworld = _mediaElement->platformMedia().media.gstreamerGWorld;
+ if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::GStreamerGWorldType) {
+ GStreamerGWorld* gstGworld = _mediaElement->platformMedia().media.gstreamerGWorld;
if (gstGworld->enterFullscreen())
[window setContentView:gstGworld->platformVideoWindow()->window()];
}
#else
[[window contentView] setLayer:layer];
[[window contentView] setWantsLayer:YES];
- if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::QTMovieType)
+ if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::QTMovieType)
[layer setMovie:_mediaElement->platformMedia().media.qtMovie];
#endif
}
@@ -134,12 +132,12 @@
#endif
}
-- (WebCore::HTMLMediaElement*)mediaElement
+- (HTMLMediaElement*)mediaElement
{
return _mediaElement.get();
}
-- (void)setMediaElement:(WebCore::HTMLMediaElement*)mediaElement
+- (void)setMediaElement:(HTMLMediaElement*)mediaElement
{
_mediaElement = mediaElement;
if ([self isWindowLoaded]) {
@@ -180,7 +178,7 @@
- (void)windowDidExitFullscreen
{
#if USE(GSTREAMER)
- if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::GStreamerGWorldType)
+ if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::GStreamerGWorldType)
_mediaElement->platformMedia().media.gstreamerGWorld->exitFullscreen();
#endif
[self clearFadeAnimation];
@@ -365,76 +363,17 @@
SetSystemUIMode(_isEndingFullscreen ? kUIModeNormal : kUIModeAllHidden, 0);
}
-- (void)_disableIdleDisplaySleep
-{
- if (_idleDisplaySleepAssertion == kIOPMNullAssertionID)
-#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK
- IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);
-#else // IOPMAssertionCreate is depreciated in > 10.5
- IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleDisplaySleepAssertion);
-#endif
-}
-
-- (void)_enableIdleDisplaySleep
-{
- if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) {
- IOPMAssertionRelease(_idleDisplaySleepAssertion);
- _idleDisplaySleepAssertion = kIOPMNullAssertionID;
- }
-}
-
-- (void)_disableIdleSystemSleep
-{
- if (_idleSystemSleepAssertion == kIOPMNullAssertionID)
-#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK
- IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion);
-#else // IOPMAssertionCreate is depreciated in > 10.5
- IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleSystemSleepAssertion);
-#endif
-}
-
-- (void)_enableIdleSystemSleep
-{
- if (_idleSystemSleepAssertion != kIOPMNullAssertionID) {
- IOPMAssertionRelease(_idleSystemSleepAssertion);
- _idleSystemSleepAssertion = kIOPMNullAssertionID;
- }
-}
-
-- (void)_enableTickleTimer
-{
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain];
-}
-
-- (void)_disableTickleTimer
-{
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = nil;
-}
-
-- (void)_tickleTimerFired
-{
- UpdateSystemActivity(OverallAct);
-}
-
- (void)updatePowerAssertions
{
float rate = 0;
- if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::QTMovieType)
+ if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::QTMovieType)
rate = [_mediaElement->platformMedia().media.qtMovie rate];
if (rate && !_isEndingFullscreen) {
- [self _disableIdleSystemSleep];
- [self _disableIdleDisplaySleep];
- [self _enableTickleTimer];
- } else {
- [self _enableIdleSystemSleep];
- [self _enableIdleDisplaySleep];
- [self _disableTickleTimer];
- }
+ if (!_displaySleepDisabler)
+ _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebCore - Fullscreen video");
+ } else
+ _displaySleepDisabler = nullptr;
}
// MARK: -
Modified: trunk/Source/WebKit/mac/ChangeLog (95512 => 95513)
--- trunk/Source/WebKit/mac/ChangeLog 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebKit/mac/ChangeLog 2011-09-20 04:14:55 UTC (rev 95513)
@@ -1,3 +1,22 @@
+2011-09-19 Mark Rowe <mr...@apple.com>
+
+ <http://webkit.org/b/68421> Stop calling UpdateSystemActivity in places where we hold power assertions that achieve the same effect
+
+ On SnowLeopard and newer it's not necessary to call UpdateSystemActivity to prevent the screensaver from kicking
+ in as the NoDisplaySleep assertion now has that effect. It's also not necessary to hold both a NoDisplaySleep and
+ a NoIdleSleep assertion as the latter is implied by the former.
+
+ Adopt the DisplaySleepDisabler class that was added to WebCore and remove all of duplicated logic from WebFullScreenController.
+
+ Reviewed by Dan Bernstein.
+
+ * WebView/WebFullScreenController.h:
+ * WebView/WebFullScreenController.mm:
+ (-[WebFullScreenController dealloc]):
+ (-[WebFullScreenController _updatePowerAssertions]): Create a DisplaySleepDisabler instance when transitioning from permitting
+ display sleep to disabling display sleep. Clear out our reference when sleep should be permitted, destroying any
+ disabler that we own.
+
2011-09-19 Adam Barth <aba...@webkit.org>
Always enable ENABLE(EVENTSOURCE)
Modified: trunk/Source/WebKit/mac/WebView/WebFullScreenController.h (95512 => 95513)
--- trunk/Source/WebKit/mac/WebView/WebFullScreenController.h 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebKit/mac/WebView/WebFullScreenController.h 2011-09-20 04:14:55 UTC (rev 95513)
@@ -25,11 +25,13 @@
#if ENABLE(FULLSCREEN_API)
+#import <wtf/OwnPtr.h>
#import <wtf/RefPtr.h>
@class WebWindowFadeAnimation;
@class WebView;
namespace WebCore {
+ class DisplaySleepDisabler;
class Element;
class RenderBox;
class EventListener;
@@ -46,9 +48,7 @@
BOOL _isAnimating;
BOOL _isFullscreen;
BOOL _forceDisableAnimation;
- uint32_t _idleDisplaySleepAssertion;
- uint32_t _idleSystemSleepAssertion;
- NSTimer *_tickleTimer;
+ OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler;
CGRect _initialFrame;
}
Modified: trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm (95512 => 95513)
--- trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm 2011-09-20 04:14:55 UTC (rev 95513)
@@ -35,27 +35,27 @@
#import <WebCore/AnimationList.h>
#import <WebCore/CSSPropertyNames.h>
#import <WebCore/Color.h>
-#import <WebCore/Document.h>
#import <WebCore/DOMDocument.h>
#import <WebCore/DOMDocumentInternal.h>
#import <WebCore/DOMHTMLElement.h>
#import <WebCore/DOMWindow.h>
+#import <WebCore/DisplaySleepDisabler.h>
+#import <WebCore/Document.h>
#import <WebCore/EventListener.h>
#import <WebCore/EventNames.h>
#import <WebCore/HTMLElement.h>
-#import <WebCore/HTMLNames.h>
#import <WebCore/HTMLMediaElement.h>
+#import <WebCore/HTMLNames.h>
#import <WebCore/IntRect.h>
#import <WebCore/NodeList.h>
-#import <WebCore/SoftLinking.h>
#import <WebCore/RenderBlock.h>
#import <WebCore/RenderLayer.h>
#import <WebCore/RenderLayerBacking.h>
+#import <WebCore/SoftLinking.h>
#import <objc/objc-runtime.h>
#import <wtf/RetainPtr.h>
#import <wtf/UnusedParam.h>
-static const NSTimeInterval tickleTimerInterval = 1.0;
static NSString* const isEnteringFullscreenKey = @"isEnteringFullscreen";
using namespace WebCore;
@@ -121,8 +121,6 @@
- (void)dealloc
{
- ASSERT(!_tickleTimer);
-
[self setWebView:nil];
[_placeholderView release];
@@ -645,74 +643,15 @@
SetSystemUIMode(_isFullscreen ? kUIModeNormal : kUIModeAllHidden, 0);
}
-- (void)_disableIdleDisplaySleep
-{
- if (_idleDisplaySleepAssertion == kIOPMNullAssertionID)
-#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK
- IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);
-#else // IOPMAssertionCreate is depreciated in > 10.5
- IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleDisplaySleepAssertion);
-#endif
-}
-
-- (void)_enableIdleDisplaySleep
-{
- if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) {
- IOPMAssertionRelease(_idleDisplaySleepAssertion);
- _idleDisplaySleepAssertion = kIOPMNullAssertionID;
- }
-}
-
-- (void)_disableIdleSystemSleep
-{
- if (_idleSystemSleepAssertion == kIOPMNullAssertionID)
-#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK
- IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion);
-#else // IOPMAssertionCreate is depreciated in > 10.5
- IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleSystemSleepAssertion);
-#endif
-}
-
-- (void)_enableIdleSystemSleep
-{
- if (_idleSystemSleepAssertion != kIOPMNullAssertionID) {
- IOPMAssertionRelease(_idleSystemSleepAssertion);
- _idleSystemSleepAssertion = kIOPMNullAssertionID;
- }
-}
-
-- (void)_enableTickleTimer
-{
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain];
-}
-
-- (void)_disableTickleTimer
-{
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = nil;
-}
-
-- (void)_tickleTimerFired
-{
- UpdateSystemActivity(OverallAct);
-}
-
- (void)_updatePowerAssertions
{
BOOL isPlaying = [self _isAnyMoviePlaying];
if (isPlaying && _isFullscreen) {
- [self _disableIdleSystemSleep];
- [self _disableIdleDisplaySleep];
- [self _enableTickleTimer];
- } else {
- [self _enableIdleSystemSleep];
- [self _enableIdleDisplaySleep];
- [self _disableTickleTimer];
- }
+ if (!_displaySleepDisabler)
+ _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebKit - Fullscreen video");
+ } else
+ _displaySleepDisabler = nullptr;
}
- (void)_requestExit
Modified: trunk/Source/WebKit2/ChangeLog (95512 => 95513)
--- trunk/Source/WebKit2/ChangeLog 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebKit2/ChangeLog 2011-09-20 04:14:55 UTC (rev 95513)
@@ -1,3 +1,21 @@
+2011-09-19 Mark Rowe <mr...@apple.com>
+
+ <http://webkit.org/b/68421> Stop calling UpdateSystemActivity in places where we hold power assertions that achieve the same effect
+
+ On SnowLeopard and newer it's not necessary to call UpdateSystemActivity to prevent the screensaver from kicking
+ in as the NoDisplaySleep assertion now has that effect. It's also not necessary to hold both a NoDisplaySleep and
+ a NoIdleSleep assertion as the latter is implied by the former.
+
+ Adopt the DisplaySleepDisabler class that was added to WebCore and remove all of duplicated logic from WKFullScreenWindowController.
+
+ Reviewed by Dan Bernstein.
+
+ * UIProcess/mac/WKFullScreenWindowController.h:
+ * UIProcess/mac/WKFullScreenWindowController.mm:
+ (-[WKFullScreenWindowController _updatePowerAssertions]): Create a DisplaySleepDisabler instance when transitioning from permitting
+ display sleep to disabling display sleep. Clear out our reference when sleep should be permitted, destroying any
+ disabler that we own. Also adds a FIXME about an error that was noticed while working in this code.
+
2011-09-19 Adam Barth <aba...@webkit.org>
Always enable ENABLE(EVENTSOURCE)
Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h (95512 => 95513)
--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h 2011-09-20 04:14:55 UTC (rev 95513)
@@ -25,7 +25,7 @@
#if ENABLE(FULLSCREEN_API)
-#import <Cocoa/Cocoa.h>
+#import <wtf/OwnPtr.h>
#import <wtf/RetainPtr.h>
namespace WebKit {
@@ -33,6 +33,7 @@
}
namespace WebCore {
+class DisplaySleepDisabler;
class IntRect;
}
@@ -49,9 +50,7 @@
BOOL _isFullScreen;
BOOL _forceDisableAnimation;
BOOL _isPlaying;
- uint32_t _idleDisplaySleepAssertion;
- uint32_t _idleSystemSleepAssertion;
- NSTimer *_tickleTimer;
+ OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler;
}
- (WKView*)webView;
Modified: trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm (95512 => 95513)
--- trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm 2011-09-20 04:05:28 UTC (rev 95512)
+++ trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm 2011-09-20 04:14:55 UTC (rev 95513)
@@ -35,16 +35,14 @@
#import "WebFullScreenManagerProxy.h"
#import "WebPageProxy.h"
#import <Carbon/Carbon.h> // For SetSystemUIMode()
-#import <IOKit/pwr_mgt/IOPMLib.h> // For IOPMAssertionCreate()
#import <QuartzCore/QuartzCore.h>
+#import <WebCore/DisplaySleepDisabler.h>
#import <WebCore/FloatRect.h>
#import <WebCore/IntRect.h>
#import <WebKit/WebNSWindowExtras.h>
#import <WebKitSystemInterface.h>
#import <wtf/UnusedParam.h>
-static const NSTimeInterval tickleTimerInterval = 1.0;
-
using namespace WebKit;
using namespace WebCore;
@@ -471,72 +469,14 @@
SetSystemUIMode(_isFullScreen ? kUIModeNormal : kUIModeAllHidden, 0);
}
-- (void)_disableIdleDisplaySleep
-{
- if (_idleDisplaySleepAssertion == kIOPMNullAssertionID)
-#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK
- IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);
-#else // IOPMAssertionCreate is depreciated in > 10.5
- IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullScreen."), &_idleDisplaySleepAssertion);
-#endif
-}
-
-- (void)_enableIdleDisplaySleep
-{
- if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) {
- IOPMAssertionRelease(_idleDisplaySleepAssertion);
- _idleDisplaySleepAssertion = kIOPMNullAssertionID;
- }
-}
-
-- (void)_disableIdleSystemSleep
-{
- if (_idleSystemSleepAssertion == kIOPMNullAssertionID)
-#if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK
- IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion);
-#else // IOPMAssertionCreate is depreciated in > 10.5
- IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullScreen."), &_idleSystemSleepAssertion);
-#endif
-}
-
-- (void)_enableIdleSystemSleep
-{
- if (_idleSystemSleepAssertion != kIOPMNullAssertionID) {
- IOPMAssertionRelease(_idleSystemSleepAssertion);
- _idleSystemSleepAssertion = kIOPMNullAssertionID;
- }
-}
-
-- (void)_enableTickleTimer
-{
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain];
-}
-
-- (void)_disableTickleTimer
-{
- [_tickleTimer invalidate];
- [_tickleTimer release];
- _tickleTimer = nil;
-}
-
-- (void)_tickleTimerFired
-{
- UpdateSystemActivity(OverallAct);
-}
-
- (void)_updatePowerAssertions
{
+ // FIXME: _isPlaying is never modified so we never disable display sleep here! (<rdar://problem/10151029>)
if (_isPlaying && _isFullScreen) {
- [self _disableIdleSystemSleep];
- [self _disableIdleDisplaySleep];
- [self _enableTickleTimer];
- } else {
- [self _enableIdleSystemSleep];
- [self _enableIdleDisplaySleep];
- [self _disableTickleTimer];
- }
+ if (!_displaySleepDisabler)
+ _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebKit2 - Fullscreen video");
+ } else
+ _displaySleepDisabler = nullptr;
}
- (WebPageProxy*)_page