Changeset 166247 in webkit


Ignore:
Timestamp:
Mar 25, 2014 1:25:52 PM (10 years ago)
Author:
jer.noble@apple.com
Message:

[iOS] Playing video does not disable display sleep.
https://bugs.webkit.org/show_bug.cgi?id=130729

Reviewed by Eric Carlson.

DisplaySleepDisabler was broken by r161589, which replaced the iOS implementation with
an empty one. Make a platform independent version with a Cocoa-platform subclass. Update
the APIs to non-deprecated ones.

  • platform/DisplaySleepDisabler.cpp: Added.

(WebCore::DisplaySleepDisabler::create):

  • platform/DisplaySleepDisabler.h: Added.

(WebCore::DisplaySleepDisabler::~DisplaySleepDisabler):
(WebCore::DisplaySleepDisabler::DisplaySleepDisabler):

  • platform/cocoa/DisplaySleepDisablerCocoa.cpp: Renamed from Source/WebCore/platform/mac/DisplaySleepDisabler.cpp.

(WebCore::DisplaySleepDisabler::create):
(WebCore::DisplaySleepDisablerCocoa::DisplaySleepDisablerCocoa):
(WebCore::DisplaySleepDisablerCocoa::~DisplaySleepDisablerCocoa):

  • platform/cocoa/DisplaySleepDisablerCocoa.h: Renamed from Source/WebCore/platform/mac/DisplaySleepDisabler.h.

Update m_sleepDisabler to be a std::unique_ptr, and unprotect the definition of methods which use it.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::updateSleepDisabling):
(WebCore::HTMLMediaElement::shouldDisableSleep):

  • html/HTMLMediaElement.h:

Add the new and renamed files to the project:

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • WebCore.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebCore
Files:
2 added
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r166179 r166247  
    17891789    platform/DateComponents.cpp
    17901790    platform/Decimal.cpp
     1791    platform/DisplaySleepDisabler.cpp
    17911792    platform/DragData.cpp
    17921793    platform/DragImage.cpp
  • trunk/Source/WebCore/ChangeLog

    r166246 r166247  
     12014-03-25  Jer Noble  <jer.noble@apple.com>
     2
     3        [iOS] Playing video does not disable display sleep.
     4        https://bugs.webkit.org/show_bug.cgi?id=130729
     5
     6        Reviewed by Eric Carlson.
     7
     8        DisplaySleepDisabler was broken by r161589, which replaced the iOS implementation with
     9        an empty one. Make a platform independent version with a Cocoa-platform subclass. Update
     10        the APIs to non-deprecated ones.
     11
     12        * platform/DisplaySleepDisabler.cpp: Added.
     13        (WebCore::DisplaySleepDisabler::create):
     14        * platform/DisplaySleepDisabler.h: Added.
     15        (WebCore::DisplaySleepDisabler::~DisplaySleepDisabler):
     16        (WebCore::DisplaySleepDisabler::DisplaySleepDisabler):
     17        * platform/cocoa/DisplaySleepDisablerCocoa.cpp: Renamed from Source/WebCore/platform/mac/DisplaySleepDisabler.cpp.
     18        (WebCore::DisplaySleepDisabler::create):
     19        (WebCore::DisplaySleepDisablerCocoa::DisplaySleepDisablerCocoa):
     20        (WebCore::DisplaySleepDisablerCocoa::~DisplaySleepDisablerCocoa):
     21        * platform/cocoa/DisplaySleepDisablerCocoa.h: Renamed from Source/WebCore/platform/mac/DisplaySleepDisabler.h.
     22
     23        Update m_sleepDisabler to be a std::unique_ptr, and unprotect the definition of methods which use it.
     24        * html/HTMLMediaElement.cpp:
     25        (WebCore::HTMLMediaElement::updateSleepDisabling):
     26        (WebCore::HTMLMediaElement::shouldDisableSleep):
     27        * html/HTMLMediaElement.h:
     28
     29        Add the new and renamed files to the project:
     30        * CMakeLists.txt:
     31        * GNUmakefile.list.am:
     32        * WebCore.xcodeproj/project.pbxproj:
     33
    1342014-03-25  Dirk Schulze  <krit@webkit.org>
    235
  • trunk/Source/WebCore/GNUmakefile.list.am

    r166179 r166247  
    53275327        Source/WebCore/platform/DatabaseStrategy.cpp \
    53285328        Source/WebCore/platform/DatabaseStrategy.h \
     5329        Source/WebCore/platform/DisplaySleepDisabler.cpp \
     5330        Source/WebCore/platform/DisplaySleepDisabler.h \
    53295331        Source/WebCore/platform/DragData.cpp \
    53305332        Source/WebCore/platform/DragData.h \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r166179 r166247  
    20372037                5D874F130D161D3200796C3B /* NetscapePlugInStreamLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */; };
    20382038                5D87BB8311E3ED8600702B6F /* ExportFileGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D87BB8211E3ED8600702B6F /* ExportFileGenerator.cpp */; };
    2039                 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */; };
    2040                 5D8C4DC01428222C0026CE72 /* DisplaySleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2039                5D8C4DBF1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp */; };
     2040                5D8C4DC01428222C0026CE72 /* DisplaySleepDisablerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisablerCocoa.h */; };
    20412041                5D925B670F64D4DD00B847F0 /* ScrollBehavior.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */; };
    20422042                5D925B680F64D4DD00B847F0 /* ScrollBehavior.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D925B660F64D4DD00B847F0 /* ScrollBehavior.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    55225522                CD3E252418046BCD00E27F56 /* CSSGridTemplateAreasValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3E252218046BCD00E27F56 /* CSSGridTemplateAreasValue.h */; };
    55235523                CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
     5524                CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD52481818E200ED0008A07D /* DisplaySleepDisabler.cpp */; };
     5525                CD52481B18E200ED0008A07D /* DisplaySleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = CD52481918E200ED0008A07D /* DisplaySleepDisabler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    55245526                CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */; };
    55255527                CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5393D2175E018600C07123 /* JSMemoryInfo.h */; };
     
    90259027                5D87BB4F11E3EAEB00702B6F /* WebCoreExportFileGenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = WebCoreExportFileGenerator; sourceTree = BUILT_PRODUCTS_DIR; };
    90269028                5D87BB8211E3ED8600702B6F /* ExportFileGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExportFileGenerator.cpp; path = DerivedSources/WebCore/ExportFileGenerator.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
    9027                 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplaySleepDisabler.cpp; sourceTree = "<group>"; };
    9028                 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplaySleepDisabler.h; sourceTree = "<group>"; };
     9029                5D8C4DBD1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplaySleepDisablerCocoa.cpp; sourceTree = "<group>"; };
     9030                5D8C4DBE1428222C0026CE72 /* DisplaySleepDisablerCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplaySleepDisablerCocoa.h; sourceTree = "<group>"; };
    90299031                5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollBehavior.cpp; sourceTree = "<group>"; };
    90309032                5D925B660F64D4DD00B847F0 /* ScrollBehavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBehavior.h; sourceTree = "<group>"; };
     
    1282412826                CD4AC5281496AE2F0087C4EF /* Composite.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = Composite.wav; path = platform/audio/resources/Composite.wav; sourceTree = SOURCE_ROOT; };
    1282512827                CD4E0AFA11F7BC27009D3811 /* fullscreen.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = fullscreen.css; sourceTree = "<group>"; };
     12828                CD52481818E200ED0008A07D /* DisplaySleepDisabler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplaySleepDisabler.cpp; sourceTree = "<group>"; };
     12829                CD52481918E200ED0008A07D /* DisplaySleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplaySleepDisabler.h; sourceTree = "<group>"; };
    1282612830                CD5393CB175DCCE600C07123 /* MemoryInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInfo.h; sourceTree = "<group>"; };
    1282712831                CD5393CC175DCCE600C07123 /* MemoryInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MemoryInfo.idl; sourceTree = "<group>"; };
     
    1607216076                                93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */,
    1607316077                                F58784F002DE375901EA4122 /* CursorMac.mm */,
    16074                                 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisabler.cpp */,
    16075                                 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisabler.h */,
    1607616078                                A795463D0B5C4C80007B438F /* DragDataMac.mm */,
    1607716079                                A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */,
     
    1815818160                        isa = PBXGroup;
    1815918161                        children = (
     18162                                5D8C4DBD1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp */,
     18163                                5D8C4DBE1428222C0026CE72 /* DisplaySleepDisablerCocoa.h */,
    1816018164                                A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */,
    1816118165                                A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */,
     
    2091020914                                45FEA5CD156DDE8C00654101 /* Decimal.cpp */,
    2091120915                                45FEA5CE156DDE8C00654101 /* Decimal.h */,
     20916                                CD52481818E200ED0008A07D /* DisplaySleepDisabler.cpp */,
     20917                                CD52481918E200ED0008A07D /* DisplaySleepDisabler.h */,
    2091220918                                A79546420B5C4CB4007B438F /* DragData.cpp */,
    2091320919                                A7B6E69D0B291A9600D0529F /* DragData.h */,
     
    2331323319                                A5F9EF711266750D00FCCF52 /* DiskImageCacheIOS.h in Headers */,
    2331423320                                49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */,
    23315                                 5D8C4DC01428222C0026CE72 /* DisplaySleepDisabler.h in Headers */,
     23321                                5D8C4DC01428222C0026CE72 /* DisplaySleepDisablerCocoa.h in Headers */,
    2331623322                                FD31609112B026F700C1A359 /* Distance.h in Headers */,
    2331723323                                84730D771248F0B300D3A9C9 /* DistantLightSource.h in Headers */,
     
    2617126177                                2E43464D0F546A8200B0F1BA /* WorkerLocation.h in Headers */,
    2617226178                                2E4346500F546A8200B0F1BA /* WorkerMessagingProxy.h in Headers */,
     26179                                CD52481B18E200ED0008A07D /* DisplaySleepDisabler.h in Headers */,
    2617326180                                E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */,
    2617426181                                1ABC7109170E5E1B00F9A9D6 /* WorkerNavigatorStorageQuota.h in Headers */,
     
    2692726934                                0F97A658155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm in Sources */,
    2692826935                                49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
    26929                                 5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */,
     26936                                5D8C4DBF1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp in Sources */,
    2693026937                                FD31609012B026F700C1A359 /* Distance.cpp in Sources */,
    2693126938                                A1E1154413015C3D0054AC8C /* DistantLightSource.cpp in Sources */,
     
    2743927446                                5126E6BB0A2E3B12005C29FA /* IconDatabase.cpp in Sources */,
    2744027447                                516953971329A3C800B92D04 /* IconDatabaseBase.cpp in Sources */,
     27448                                CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */,
    2744127449                                FED13D400CEA939400D89466 /* IconIOS.mm in Sources */,
    2744227450                                513F14530AB634C400094DDF /* IconLoader.cpp in Sources */,
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r166238 r166247  
    56405640void HTMLMediaElement::updateSleepDisabling()
    56415641{
    5642 #if PLATFORM(COCOA)
    56435642    if (!shouldDisableSleep() && m_sleepDisabler)
    56445643        m_sleepDisabler = nullptr;
    56455644    else if (shouldDisableSleep() && !m_sleepDisabler)
    56465645        m_sleepDisabler = DisplaySleepDisabler::create("com.apple.WebCore: HTMLMediaElement playback");
    5647 #endif
    56485646}
    56495647
     
    56515649bool HTMLMediaElement::shouldDisableSleep() const
    56525650{
     5651#if !PLATFORM(COCOA)
     5652    return false;
     5653#endif
     5654
    56535655#if ENABLE(PAGE_VISIBILITY_API)
    56545656    if (m_isDisplaySleepDisablingSuspended)
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r166238 r166247  
    6363class MediaElementAudioSourceNode;
    6464#endif
     65class DisplaySleepDisabler;
    6566class Event;
    6667class HTMLSourceElement;
     
    7576#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
    7677class Widget;
    77 #endif
    78 #if PLATFORM(COCOA)
    79 class DisplaySleepDisabler;
    8078#endif
    8179#if ENABLE(ENCRYPTED_MEDIA_V2)
     
    865863    RefPtr<MediaController> m_mediaController;
    866864
    867 #if PLATFORM(COCOA)
    868     OwnPtr<DisplaySleepDisabler> m_sleepDisabler;
    869 #endif
     865    std::unique_ptr<DisplaySleepDisabler> m_sleepDisabler;
    870866
    871867    friend class TrackDisplayUpdateScope;
  • trunk/Source/WebCore/platform/cocoa/DisplaySleepDisablerCocoa.cpp

    r166246 r166247  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "DisplaySleepDisabler.h"
     27#include "DisplaySleepDisablerCocoa.h"
    2828
    29 #if !PLATFORM(IOS)
     29#if PLATFORM(COCOA)
    3030
    3131#include <IOKit/pwr_mgt/IOPMLib.h>
     
    3434namespace WebCore {
    3535
    36 #if PLATFORM(IOS)
    37 static const double systemActivityInterval = 1;
    38 #endif
    39 
    40 DisplaySleepDisabler::DisplaySleepDisabler(const char* reason)
    41     : m_disableDisplaySleepAssertion(0)
     36std::unique_ptr<DisplaySleepDisabler> DisplaySleepDisabler::create(const char* reason)
    4237{
    43 #if !PLATFORM(IOS)
    44     RetainPtr<CFStringRef> reasonCF = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, reason, kCFStringEncodingUTF8));
    45     IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonCF.get(), &m_disableDisplaySleepAssertion);
    46 #else
    47     UNUSED_PARAM(reason);
    48     IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &m_disableDisplaySleepAssertion);
    49     m_systemActivityTimer.startRepeating(systemActivityInterval);
    50 #endif
     38    return std::unique_ptr<DisplaySleepDisabler>(new DisplaySleepDisabler(reason));
    5139}
    5240
    53 DisplaySleepDisabler::~DisplaySleepDisabler()
     41DisplaySleepDisablerCocoa::DisplaySleepDisablerCocoa(const char* reason)
     42    : DisplaySleepDisabler(reason)
     43    , m_disableDisplaySleepAssertion(0)
     44{
     45    RetainPtr<CFStringRef> reasonCF = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, reason, kCFStringEncodingUTF8));
     46    IOPMAssertionCreateWithDescription(kIOPMAssertionTypePreventUserIdleDisplaySleep, reasonCF.get(), nullptr, nullptr, nullptr, 0, nullptr, &m_disableDisplaySleepAssertion);
     47}
     48
     49DisplaySleepDisablerCocoa::~DisplaySleepDisablerCocoa()
    5450{
    5551    IOPMAssertionRelease(m_disableDisplaySleepAssertion);
     
    5854}
    5955
    60 #else
    61 
    62 namespace WebCore {
    63 DisplaySleepDisabler::DisplaySleepDisabler(const char *) { }
    64 DisplaySleepDisabler::~DisplaySleepDisabler() { }
    65 }
    66 
    67 #endif // !PLATFORM(IOS)
     56#endif // PLATFORM(COCOA)
  • trunk/Source/WebCore/platform/cocoa/DisplaySleepDisablerCocoa.h

    r166246 r166247  
    2424 */
    2525
    26 #ifndef DisplaySleepDisabler_h
    27 #define DisplaySleepDisabler_h
     26#ifndef DisplaySleepDisablerCocoa_h
     27#define DisplaySleepDisablerCocoa_h
    2828
    29 #include <wtf/Noncopyable.h>
    30 #include <wtf/PassOwnPtr.h>
     29#if PLATFORM(COCOA)
     30
     31#include "DisplaySleepDisabler.h"
    3132
    3233namespace WebCore {
    3334
    34 class DisplaySleepDisabler {
    35     WTF_MAKE_NONCOPYABLE(DisplaySleepDisabler);
     35class DisplaySleepDisablerCocoa : public DisplaySleepDisabler {
    3636public:
    37     static PassOwnPtr<DisplaySleepDisabler> create(const char* reason) { return adoptPtr(new DisplaySleepDisabler(reason)); }
    38     ~DisplaySleepDisabler();
    39    
     37    virtual ~DisplaySleepDisablerCocoa();
     38
    4039private:
    41     DisplaySleepDisabler(const char* reason);
    42    
    43 #if !PLATFORM(IOS)
     40    DisplaySleepDisablerCocoa(const char*);
     41
    4442    uint32_t m_disableDisplaySleepAssertion;
    45 #endif // !PLATFORM(IOS)
    4643};
    4744
    4845}
    4946
    50 #endif // DisplaySleepDisabler_h
     47#endif // PLATFORM(COCOA)
     48
     49#endif // DisplaySleepDisablerCocoa_h
Note: See TracChangeset for help on using the changeset viewer.