Changeset 95513 in webkit
- Timestamp:
- Sep 19, 2011 9:14:55 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95509 r95513 1 2011-09-19 Mark Rowe <mrowe@apple.com> 2 3 <http://webkit.org/b/68421> Stop calling UpdateSystemActivity in places where we hold power assertions that achieve the same effect 4 5 On SnowLeopard and newer it's not necessary to call UpdateSystemActivity to prevent the screensaver from kicking 6 in as the NoDisplaySleep assertion now has that effect. It's also not necessary to hold both a NoDisplaySleep and 7 a NoIdleSleep assertion as the latter is implied by the former. 8 9 Since there were multiple copies of the same code to disable display sleep spread across WebCore, WebKit and WebKit2 10 this patch takes the approach of moving this functionality to a new DisplaySleepDisabler class that lives in WebCore. 11 A class is used as it makes it easier to reason about the lifetime of the assertions and to ensure that the assertions will 12 always be released when their owning objects go away. 13 14 Reviewed by Dan Bernstein. 15 16 * WebCore.exp.in: 17 * WebCore.xcodeproj/project.pbxproj: 18 * platform/mac/DisplaySleepDisabler.cpp: 19 (WebCore::DisplaySleepDisabler::DisplaySleepDisabler): Register for the NoDisplaySleep assertion, and start our 20 system activity timer when on Leopard. 21 (WebCore::DisplaySleepDisabler::~DisplaySleepDisabler): Unregister for the assertion. 22 (WebCore::DisplaySleepDisabler::systemActivityTimerFired): Call UpdateSystemActivity to prevent the screensaver from 23 triggering on Leopard. 24 * platform/mac/DisplaySleepDisabler.h: 25 (WebCore::DisplaySleepDisabler::create): 26 * platform/mac/WebVideoFullscreenController.h: 27 * platform/mac/WebVideoFullscreenController.mm: 28 (-[WebVideoFullscreenController dealloc]): 29 (-[WebVideoFullscreenController setupVideoOverlay:]): Remove the now-unnecessary explicit use of the WebCore namespace. 30 (-[WebVideoFullscreenController mediaElement]): Ditto. 31 (-[WebVideoFullscreenController setMediaElement:]): Ditto. 32 (-[WebVideoFullscreenController windowDidExitFullscreen]): Ditto. 33 (-[WebVideoFullscreenController updatePowerAssertions]): Create a DisplaySleepDisabler instance when transitioning from permitting 34 display sleep to disabling display sleep. Clear out our reference when sleep should be permitted, destroying any 35 disabler that we own. 36 1 37 2011-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 38 -
trunk/Source/WebCore/WebCore.exp.in
r95372 r95513 550 550 __ZN7WebCore19TextResourceDecoderD1Ev 551 551 __ZN7WebCore19applicationIsSafariEv 552 __ZN7WebCore20DisplaySleepDisablerC1EPKc 553 __ZN7WebCore20DisplaySleepDisablerD1Ev 552 554 __ZN7WebCore20NodeRenderingContextC1EPNS_4NodeE 553 555 __ZN7WebCore20NodeRenderingContextD1Ev -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r95486 r95513 1552 1552 5D88EE9111407FD300BC3ABC /* DOMSVGFEMorphologyElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 84224189107E786F00766A87 /* DOMSVGFEMorphologyElement.h */; }; 1553 1553 5D88EE9211407FF400BC3ABC /* DOMSVGFEMorphologyElementInternal.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 8422418B107E786F00766A87 /* DOMSVGFEMorphologyElementInternal.h */; }; 1554 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */; }; 1555 5D8C4DC01428222C0026CE72 /* DisplaySleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1554 1556 5D925B670F64D4DD00B847F0 /* ScrollBehavior.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */; }; 1555 1557 5D925B680F64D4DD00B847F0 /* ScrollBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D925B660F64D4DD00B847F0 /* ScrollBehavior.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8210 8212 5D87BB4F11E3EAEB00702B6F /* WebCoreExportFileGenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = WebCoreExportFileGenerator; sourceTree = BUILT_PRODUCTS_DIR; }; 8211 8213 5D87BB8211E3ED8600702B6F /* ExportFileGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExportFileGenerator.cpp; path = DerivedSources/WebCore/ExportFileGenerator.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; 8214 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplaySleepDisabler.cpp; sourceTree = "<group>"; }; 8215 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplaySleepDisabler.h; sourceTree = "<group>"; }; 8212 8216 5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollBehavior.cpp; sourceTree = "<group>"; }; 8213 8217 5D925B660F64D4DD00B847F0 /* ScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBehavior.h; sourceTree = "<group>"; }; … … 14529 14533 isa = PBXGroup; 14530 14534 children = ( 14531 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */,14532 14535 51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */, 14533 14536 65A640F00533BB1F0085E777 /* BlockExceptions.h */, … … 14539 14542 9352087609BD453400F2038D /* CookieJar.mm */, 14540 14543 F58784F002DE375901EA4122 /* CursorMac.mm */, 14544 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */, 14545 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */, 14541 14546 A795463D0B5C4C80007B438F /* DragDataMac.mm */, 14542 14547 A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */, … … 14557 14562 657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */, 14558 14563 BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */, 14564 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */, 14559 14565 A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */, 14560 14566 4B2709810AF2E5E00065127F /* PasteboardMac.mm */, … … 20463 20469 buildActionMask = 2147483647; 20464 20470 files = ( 20471 5D8C4DC01428222C0026CE72 /* DisplaySleepDisabler.h in Headers */, 20465 20472 B5B5DC6A119BB3D5002A8790 /* AbstractDatabase.h in Headers */, 20466 20473 41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */, … … 26311 26318 9752D38D1413104B003305BD /* JSHTMLSpanElement.cpp in Sources */, 26312 26319 0FE71405142170B800DB33BA /* ScrollbarThemeMock.cpp in Sources */, 26320 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */, 26313 26321 ); 26314 26322 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.cpp
r95512 r95513 24 24 */ 25 25 26 #if ENABLE(FULLSCREEN_API) 26 #include "config.h" 27 #include "DisplaySleepDisabler.h" 27 28 28 #i mport <Cocoa/Cocoa.h>29 #i mport<wtf/RetainPtr.h>29 #include <IOKit/pwr_mgt/IOPMLib.h> 30 #include <wtf/RetainPtr.h> 30 31 31 namespace WebKit { 32 class LayerTreeContext; 32 #ifdef BUILDING_ON_LEOPARD 33 #include <wtf/UnusedParam.h> 34 #endif 35 36 namespace WebCore { 37 38 static const double systemActivityInterval = 1; 39 40 DisplaySleepDisabler::DisplaySleepDisabler(const char* reason) 41 : m_disableDisplaySleepAssertion(0) 42 #ifdef BUILDING_ON_LEOPARD 43 , m_systemActivityTimer(this, &DisplaySleepDisabler::systemActivityTimerFired) 44 #endif 45 { 46 #ifndef BUILDING_ON_LEOPARD 47 RetainPtr<CFStringRef> reasonCF(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, reason, kCFStringEncodingUTF8)); 48 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonCF.get(), &m_disableDisplaySleepAssertion); 49 #else 50 UNUSED_PARAM(reason); 51 IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion); 52 m_systemActivityTimer.startRepeating(systemActivityInterval); 53 #endif 33 54 } 34 55 35 namespace WebCore { 36 class IntRect; 56 DisplaySleepDisabler::~DisplaySleepDisabler() 57 { 58 IOPMAssertionRelease(m_disableDisplaySleepAssertion); 37 59 } 60 61 #ifdef BUILDING_ON_LEOPARD 62 void DisplaySleepDisabler::systemActivityTimerFired(Timer<DisplaySleepDisabler>*) 63 { 64 UpdateSystemActivity(OverallAct); 65 } 66 #endif 38 67 39 @class WKView;40 41 @interface WKFullScreenWindowController : NSWindowController {42 @private43 WKView *_webView;44 RetainPtr<NSView> _webViewPlaceholder;45 RetainPtr<NSView> _layerHostingView;46 47 BOOL _isEnteringFullScreen;48 BOOL _isExitingFullScreen;49 BOOL _isFullScreen;50 BOOL _forceDisableAnimation;51 BOOL _isPlaying;52 uint32_t _idleDisplaySleepAssertion;53 uint32_t _idleSystemSleepAssertion;54 NSTimer *_tickleTimer;55 68 } 56 57 - (WKView*)webView;58 - (void)setWebView:(WKView*)webView;59 60 - (void)enterFullScreen:(NSScreen *)screen;61 - (void)exitFullScreen;62 - (void)beganEnterFullScreenAnimation;63 - (void)beganExitFullScreenAnimation;64 - (void)finishedEnterFullScreenAnimation:(bool)completed;65 - (void)finishedExitFullScreenAnimation:(bool)completed;66 - (void)enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)context;67 - (void)exitAcceleratedCompositingMode;68 - (WebCore::IntRect)getFullScreenRect;69 - (void)close;70 71 @end72 73 #endif -
trunk/Source/WebCore/platform/mac/DisplaySleepDisabler.h
r95512 r95513 24 24 */ 25 25 26 #if ENABLE(FULLSCREEN_API) 26 #ifndef DisplaySleepDisabler_h 27 #define DisplaySleepDisabler_h 27 28 28 #i mport <Cocoa/Cocoa.h>29 #i mport <wtf/RetainPtr.h>29 #include <wtf/Noncopyable.h> 30 #include <wtf/PassOwnPtr.h> 30 31 31 namespace WebKit { 32 class LayerTreeContext; 32 #ifdef BUILDNG_ON_LEOPARD 33 #include "Timer.h" 34 #endif 35 36 namespace WebCore { 37 38 class DisplaySleepDisabler { 39 WTF_MAKE_NONCOPYABLE(DisplaySleepDisabler); 40 public: 41 static PassOwnPtr<DisplaySleepDisabler> create(const char* reason) { return adoptPtr(new DisplaySleepDisabler(reason)); } 42 ~DisplaySleepDisabler(); 43 44 private: 45 DisplaySleepDisabler(const char* reason); 46 47 #ifdef BUILDNG_ON_LEOPARD 48 void systemActivityTimerFired(Timer<DisplaySleepDisabler>*); 49 #endif 50 51 uint32_t m_disableDisplaySleepAssertion; 52 #ifdef BUILDNG_ON_LEOPARD 53 Timer<DisplaySleepDisabler> m_systemActivityTimer; 54 #endif 55 }; 56 33 57 } 34 58 35 namespace WebCore { 36 class IntRect; 37 } 38 39 @class WKView; 40 41 @interface WKFullScreenWindowController : NSWindowController { 42 @private 43 WKView *_webView; 44 RetainPtr<NSView> _webViewPlaceholder; 45 RetainPtr<NSView> _layerHostingView; 46 47 BOOL _isEnteringFullScreen; 48 BOOL _isExitingFullScreen; 49 BOOL _isFullScreen; 50 BOOL _forceDisableAnimation; 51 BOOL _isPlaying; 52 uint32_t _idleDisplaySleepAssertion; 53 uint32_t _idleSystemSleepAssertion; 54 NSTimer *_tickleTimer; 55 } 56 57 - (WKView*)webView; 58 - (void)setWebView:(WKView*)webView; 59 60 - (void)enterFullScreen:(NSScreen *)screen; 61 - (void)exitFullScreen; 62 - (void)beganEnterFullScreenAnimation; 63 - (void)beganExitFullScreenAnimation; 64 - (void)finishedEnterFullScreenAnimation:(bool)completed; 65 - (void)finishedExitFullScreenAnimation:(bool)completed; 66 - (void)enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)context; 67 - (void)exitAcceleratedCompositingMode; 68 - (WebCore::IntRect)getFullScreenRect; 69 - (void)close; 70 71 @end 72 73 #endif 59 #endif // DisplaySleepDisabler_h -
trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.h
r93022 r95513 28 28 #import <AppKit/NSWindowController.h> 29 29 #import <AppKit/NSScreen.h> 30 #import < Foundation/NSTimer.h>30 #import <wtf/OwnPtr.h> 31 31 #import <wtf/RefPtr.h> 32 32 33 33 namespace WebCore { 34 class DisplaySleepDisabler; 34 35 class HTMLMediaElement; 35 36 } … … 52 53 BOOL _isEndingFullscreen; 53 54 BOOL _forceDisableAnimation; 54 uint32_t _idleDisplaySleepAssertion; 55 uint32_t _idleSystemSleepAssertion; 56 NSTimer *_tickleTimer; 55 56 OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler; 57 57 } 58 58 -
trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm
r94846 r95513 33 33 #import "WebWindowAnimation.h" 34 34 #import <Carbon/Carbon.h> 35 #import <IOKit/pwr_mgt/IOPMLib.h>36 35 #import <QTKit/QTKit.h> 36 #import <WebCore/DisplaySleepDisabler.h> 37 37 #import <WebCore/HTMLMediaElement.h> 38 38 #import <WebCore/SoftLinking.h> … … 44 44 #endif 45 45 46 using namespace WebCore; 47 46 48 SOFT_LINK_FRAMEWORK(QTKit) 47 49 SOFT_LINK_CLASS(QTKit, QTMovieLayer) … … 50 52 51 53 #define QTMovieRateDidChangeNotification getQTMovieRateDidChangeNotification() 52 static const NSTimeInterval tickleTimerInterval = 1.0;53 54 54 55 @interface WebVideoFullscreenWindow : NSWindow … … 90 91 ASSERT(!_backgroundFullscreenWindow); 91 92 ASSERT(!_fadeAnimation); 92 [_tickleTimer invalidate];93 [_tickleTimer release];94 _tickleTimer = nil;95 93 [[NSNotificationCenter defaultCenter] removeObserver:self]; 96 94 [super dealloc]; … … 106 104 WebVideoFullscreenWindow *window = [self fullscreenWindow]; 107 105 #if USE(GSTREAMER) 108 if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::GStreamerGWorldType) {109 WebCore::GStreamerGWorld* gstGworld = _mediaElement->platformMedia().media.gstreamerGWorld;106 if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::GStreamerGWorldType) { 107 GStreamerGWorld* gstGworld = _mediaElement->platformMedia().media.gstreamerGWorld; 110 108 if (gstGworld->enterFullscreen()) 111 109 [window setContentView:gstGworld->platformVideoWindow()->window()]; … … 114 112 [[window contentView] setLayer:layer]; 115 113 [[window contentView] setWantsLayer:YES]; 116 if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::QTMovieType)114 if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::QTMovieType) 117 115 [layer setMovie:_mediaElement->platformMedia().media.qtMovie]; 118 116 #endif … … 135 133 } 136 134 137 - ( WebCore::HTMLMediaElement*)mediaElement135 - (HTMLMediaElement*)mediaElement 138 136 { 139 137 return _mediaElement.get(); 140 138 } 141 139 142 - (void)setMediaElement:( WebCore::HTMLMediaElement*)mediaElement140 - (void)setMediaElement:(HTMLMediaElement*)mediaElement 143 141 { 144 142 _mediaElement = mediaElement; … … 181 179 { 182 180 #if USE(GSTREAMER) 183 if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::GStreamerGWorldType)181 if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::GStreamerGWorldType) 184 182 _mediaElement->platformMedia().media.gstreamerGWorld->exitFullscreen(); 185 183 #endif … … 366 364 } 367 365 368 - (void)_disableIdleDisplaySleep369 {370 if (_idleDisplaySleepAssertion == kIOPMNullAssertionID)371 #if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK372 IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);373 #else // IOPMAssertionCreate is depreciated in > 10.5374 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleDisplaySleepAssertion);375 #endif376 }377 378 - (void)_enableIdleDisplaySleep379 {380 if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) {381 IOPMAssertionRelease(_idleDisplaySleepAssertion);382 _idleDisplaySleepAssertion = kIOPMNullAssertionID;383 }384 }385 386 - (void)_disableIdleSystemSleep387 {388 if (_idleSystemSleepAssertion == kIOPMNullAssertionID)389 #if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK390 IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion);391 #else // IOPMAssertionCreate is depreciated in > 10.5392 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleSystemSleepAssertion);393 #endif394 }395 396 - (void)_enableIdleSystemSleep397 {398 if (_idleSystemSleepAssertion != kIOPMNullAssertionID) {399 IOPMAssertionRelease(_idleSystemSleepAssertion);400 _idleSystemSleepAssertion = kIOPMNullAssertionID;401 }402 }403 404 - (void)_enableTickleTimer405 {406 [_tickleTimer invalidate];407 [_tickleTimer release];408 _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain];409 }410 411 - (void)_disableTickleTimer412 {413 [_tickleTimer invalidate];414 [_tickleTimer release];415 _tickleTimer = nil;416 }417 418 - (void)_tickleTimerFired419 {420 UpdateSystemActivity(OverallAct);421 }422 423 366 - (void)updatePowerAssertions 424 367 { 425 368 float rate = 0; 426 if (_mediaElement && _mediaElement->platformMedia().type == WebCore::PlatformMedia::QTMovieType)369 if (_mediaElement && _mediaElement->platformMedia().type == PlatformMedia::QTMovieType) 427 370 rate = [_mediaElement->platformMedia().media.qtMovie rate]; 428 371 429 372 if (rate && !_isEndingFullscreen) { 430 [self _disableIdleSystemSleep]; 431 [self _disableIdleDisplaySleep]; 432 [self _enableTickleTimer]; 433 } else { 434 [self _enableIdleSystemSleep]; 435 [self _enableIdleDisplaySleep]; 436 [self _disableTickleTimer]; 437 } 373 if (!_displaySleepDisabler) 374 _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebCore - Fullscreen video"); 375 } else 376 _displaySleepDisabler = nullptr; 438 377 } 439 378 -
trunk/Source/WebKit/mac/ChangeLog
r95501 r95513 1 2011-09-19 Mark Rowe <mrowe@apple.com> 2 3 <http://webkit.org/b/68421> Stop calling UpdateSystemActivity in places where we hold power assertions that achieve the same effect 4 5 On SnowLeopard and newer it's not necessary to call UpdateSystemActivity to prevent the screensaver from kicking 6 in as the NoDisplaySleep assertion now has that effect. It's also not necessary to hold both a NoDisplaySleep and 7 a NoIdleSleep assertion as the latter is implied by the former. 8 9 Adopt the DisplaySleepDisabler class that was added to WebCore and remove all of duplicated logic from WebFullScreenController. 10 11 Reviewed by Dan Bernstein. 12 13 * WebView/WebFullScreenController.h: 14 * WebView/WebFullScreenController.mm: 15 (-[WebFullScreenController dealloc]): 16 (-[WebFullScreenController _updatePowerAssertions]): Create a DisplaySleepDisabler instance when transitioning from permitting 17 display sleep to disabling display sleep. Clear out our reference when sleep should be permitted, destroying any 18 disabler that we own. 19 1 20 2011-09-19 Adam Barth <abarth@webkit.org> 2 21 -
trunk/Source/WebKit/mac/WebView/WebFullScreenController.h
r93024 r95513 26 26 #if ENABLE(FULLSCREEN_API) 27 27 28 #import <wtf/OwnPtr.h> 28 29 #import <wtf/RefPtr.h> 29 30 … … 31 32 @class WebView; 32 33 namespace WebCore { 34 class DisplaySleepDisabler; 33 35 class Element; 34 36 class RenderBox; … … 47 49 BOOL _isFullscreen; 48 50 BOOL _forceDisableAnimation; 49 uint32_t _idleDisplaySleepAssertion; 50 uint32_t _idleSystemSleepAssertion; 51 NSTimer *_tickleTimer; 51 OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler; 52 52 CGRect _initialFrame; 53 53 } -
trunk/Source/WebKit/mac/WebView/WebFullScreenController.mm
r92651 r95513 36 36 #import <WebCore/CSSPropertyNames.h> 37 37 #import <WebCore/Color.h> 38 #import <WebCore/Document.h>39 38 #import <WebCore/DOMDocument.h> 40 39 #import <WebCore/DOMDocumentInternal.h> 41 40 #import <WebCore/DOMHTMLElement.h> 42 41 #import <WebCore/DOMWindow.h> 42 #import <WebCore/DisplaySleepDisabler.h> 43 #import <WebCore/Document.h> 43 44 #import <WebCore/EventListener.h> 44 45 #import <WebCore/EventNames.h> 45 46 #import <WebCore/HTMLElement.h> 47 #import <WebCore/HTMLMediaElement.h> 46 48 #import <WebCore/HTMLNames.h> 47 #import <WebCore/HTMLMediaElement.h>48 49 #import <WebCore/IntRect.h> 49 50 #import <WebCore/NodeList.h> 50 #import <WebCore/SoftLinking.h>51 51 #import <WebCore/RenderBlock.h> 52 52 #import <WebCore/RenderLayer.h> 53 53 #import <WebCore/RenderLayerBacking.h> 54 #import <WebCore/SoftLinking.h> 54 55 #import <objc/objc-runtime.h> 55 56 #import <wtf/RetainPtr.h> 56 57 #import <wtf/UnusedParam.h> 57 58 58 static const NSTimeInterval tickleTimerInterval = 1.0;59 59 static NSString* const isEnteringFullscreenKey = @"isEnteringFullscreen"; 60 60 … … 122 122 - (void)dealloc 123 123 { 124 ASSERT(!_tickleTimer);125 126 124 [self setWebView:nil]; 127 125 [_placeholderView release]; … … 646 644 } 647 645 648 - (void)_disableIdleDisplaySleep649 {650 if (_idleDisplaySleepAssertion == kIOPMNullAssertionID)651 #if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK652 IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);653 #else // IOPMAssertionCreate is depreciated in > 10.5654 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleDisplaySleepAssertion);655 #endif656 }657 658 - (void)_enableIdleDisplaySleep659 {660 if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) {661 IOPMAssertionRelease(_idleDisplaySleepAssertion);662 _idleDisplaySleepAssertion = kIOPMNullAssertionID;663 }664 }665 666 - (void)_disableIdleSystemSleep667 {668 if (_idleSystemSleepAssertion == kIOPMNullAssertionID)669 #if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK670 IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion);671 #else // IOPMAssertionCreate is depreciated in > 10.5672 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullscreen."), &_idleSystemSleepAssertion);673 #endif674 }675 676 - (void)_enableIdleSystemSleep677 {678 if (_idleSystemSleepAssertion != kIOPMNullAssertionID) {679 IOPMAssertionRelease(_idleSystemSleepAssertion);680 _idleSystemSleepAssertion = kIOPMNullAssertionID;681 }682 }683 684 - (void)_enableTickleTimer685 {686 [_tickleTimer invalidate];687 [_tickleTimer release];688 _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain];689 }690 691 - (void)_disableTickleTimer692 {693 [_tickleTimer invalidate];694 [_tickleTimer release];695 _tickleTimer = nil;696 }697 698 - (void)_tickleTimerFired699 {700 UpdateSystemActivity(OverallAct);701 }702 703 646 - (void)_updatePowerAssertions 704 647 { … … 706 649 707 650 if (isPlaying && _isFullscreen) { 708 [self _disableIdleSystemSleep]; 709 [self _disableIdleDisplaySleep]; 710 [self _enableTickleTimer]; 711 } else { 712 [self _enableIdleSystemSleep]; 713 [self _enableIdleDisplaySleep]; 714 [self _disableTickleTimer]; 715 } 651 if (!_displaySleepDisabler) 652 _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebKit - Fullscreen video"); 653 } else 654 _displaySleepDisabler = nullptr; 716 655 } 717 656 -
trunk/Source/WebKit2/ChangeLog
r95501 r95513 1 2011-09-19 Mark Rowe <mrowe@apple.com> 2 3 <http://webkit.org/b/68421> Stop calling UpdateSystemActivity in places where we hold power assertions that achieve the same effect 4 5 On SnowLeopard and newer it's not necessary to call UpdateSystemActivity to prevent the screensaver from kicking 6 in as the NoDisplaySleep assertion now has that effect. It's also not necessary to hold both a NoDisplaySleep and 7 a NoIdleSleep assertion as the latter is implied by the former. 8 9 Adopt the DisplaySleepDisabler class that was added to WebCore and remove all of duplicated logic from WKFullScreenWindowController. 10 11 Reviewed by Dan Bernstein. 12 13 * UIProcess/mac/WKFullScreenWindowController.h: 14 * UIProcess/mac/WKFullScreenWindowController.mm: 15 (-[WKFullScreenWindowController _updatePowerAssertions]): Create a DisplaySleepDisabler instance when transitioning from permitting 16 display sleep to disabling display sleep. Clear out our reference when sleep should be permitted, destroying any 17 disabler that we own. Also adds a FIXME about an error that was noticed while working in this code. 18 1 19 2011-09-19 Adam Barth <abarth@webkit.org> 2 20 -
trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h
r93023 r95513 26 26 #if ENABLE(FULLSCREEN_API) 27 27 28 #import < Cocoa/Cocoa.h>28 #import <wtf/OwnPtr.h> 29 29 #import <wtf/RetainPtr.h> 30 30 … … 34 34 35 35 namespace WebCore { 36 class DisplaySleepDisabler; 36 37 class IntRect; 37 38 } … … 50 51 BOOL _forceDisableAnimation; 51 52 BOOL _isPlaying; 52 uint32_t _idleDisplaySleepAssertion; 53 uint32_t _idleSystemSleepAssertion; 54 NSTimer *_tickleTimer; 53 OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler; 55 54 } 56 55 -
trunk/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
r90851 r95513 36 36 #import "WebPageProxy.h" 37 37 #import <Carbon/Carbon.h> // For SetSystemUIMode() 38 #import <IOKit/pwr_mgt/IOPMLib.h> // For IOPMAssertionCreate()39 38 #import <QuartzCore/QuartzCore.h> 39 #import <WebCore/DisplaySleepDisabler.h> 40 40 #import <WebCore/FloatRect.h> 41 41 #import <WebCore/IntRect.h> … … 43 43 #import <WebKitSystemInterface.h> 44 44 #import <wtf/UnusedParam.h> 45 46 static const NSTimeInterval tickleTimerInterval = 1.0;47 45 48 46 using namespace WebKit; … … 472 470 } 473 471 474 - (void)_disableIdleDisplaySleep475 {476 if (_idleDisplaySleepAssertion == kIOPMNullAssertionID)477 #if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK478 IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_idleDisplaySleepAssertion);479 #else // IOPMAssertionCreate is depreciated in > 10.5480 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullScreen."), &_idleDisplaySleepAssertion);481 #endif482 }483 484 - (void)_enableIdleDisplaySleep485 {486 if (_idleDisplaySleepAssertion != kIOPMNullAssertionID) {487 IOPMAssertionRelease(_idleDisplaySleepAssertion);488 _idleDisplaySleepAssertion = kIOPMNullAssertionID;489 }490 }491 492 - (void)_disableIdleSystemSleep493 {494 if (_idleSystemSleepAssertion == kIOPMNullAssertionID)495 #if defined(BUILDING_ON_LEOPARD) // IOPMAssertionCreateWithName is not defined in the 10.5 SDK496 IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_idleSystemSleepAssertion);497 #else // IOPMAssertionCreate is depreciated in > 10.5498 IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("WebKit playing a video fullScreen."), &_idleSystemSleepAssertion);499 #endif500 }501 502 - (void)_enableIdleSystemSleep503 {504 if (_idleSystemSleepAssertion != kIOPMNullAssertionID) {505 IOPMAssertionRelease(_idleSystemSleepAssertion);506 _idleSystemSleepAssertion = kIOPMNullAssertionID;507 }508 }509 510 - (void)_enableTickleTimer511 {512 [_tickleTimer invalidate];513 [_tickleTimer release];514 _tickleTimer = [[NSTimer scheduledTimerWithTimeInterval:tickleTimerInterval target:self selector:@selector(_tickleTimerFired) userInfo:nil repeats:YES] retain];515 }516 517 - (void)_disableTickleTimer518 {519 [_tickleTimer invalidate];520 [_tickleTimer release];521 _tickleTimer = nil;522 }523 524 - (void)_tickleTimerFired525 {526 UpdateSystemActivity(OverallAct);527 }528 529 472 - (void)_updatePowerAssertions 530 473 { 474 // FIXME: _isPlaying is never modified so we never disable display sleep here! (<rdar://problem/10151029>) 531 475 if (_isPlaying && _isFullScreen) { 532 [self _disableIdleSystemSleep]; 533 [self _disableIdleDisplaySleep]; 534 [self _enableTickleTimer]; 535 } else { 536 [self _enableIdleSystemSleep]; 537 [self _enableIdleDisplaySleep]; 538 [self _disableTickleTimer]; 539 } 476 if (!_displaySleepDisabler) 477 _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebKit2 - Fullscreen video"); 478 } else 479 _displaySleepDisabler = nullptr; 540 480 } 541 481
Note: See TracChangeset
for help on using the changeset viewer.