Title: [228528] trunk/Source/WebCore
Revision
228528
Author
[email protected]
Date
2018-02-15 11:49:24 -0800 (Thu, 15 Feb 2018)

Log Message

Use std::make_unique instead of explicit calls to new and instead of writing create functions
https://bugs.webkit.org/show_bug.cgi?id=182821

Reviewed by Anders Carlsson.

* loader/LinkLoader.cpp:
(WebCore::createLinkPreloadResourceClient): Use std::make_unique insteadof create functions.

* loader/LinkPreloadResourceClients.h: Make constructors public, get rid of create functions,
make overrides be private and final, get rid of unnecessary public default virtual destructors
that the compiler will generate correctly without anything explicit.

* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::CDMFactoryClearKey::createCDM): Use std::make_unique instead of std::unique_ptr/new.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Use
std::make_unique instead of calling a create function.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC): Ditto.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC): Ditto.

* platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h: Made the constructor
public and got rid of the create function.
* platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm:
(WebCore::VideoFullscreenLayerManager::create): Deleted.

* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::computeFlexFactorUnitSize const):
Use std::make_unique instead of std::unique_ptr/new.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228527 => 228528)


--- trunk/Source/WebCore/ChangeLog	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/ChangeLog	2018-02-15 19:49:24 UTC (rev 228528)
@@ -1,3 +1,37 @@
+2018-02-14  Darin Adler  <[email protected]>
+
+        Use std::make_unique instead of explicit calls to new and instead of writing create functions
+        https://bugs.webkit.org/show_bug.cgi?id=182821
+
+        Reviewed by Anders Carlsson.
+
+        * loader/LinkLoader.cpp:
+        (WebCore::createLinkPreloadResourceClient): Use std::make_unique insteadof create functions.
+
+        * loader/LinkPreloadResourceClients.h: Make constructors public, get rid of create functions,
+        make overrides be private and final, get rid of unnecessary public default virtual destructors
+        that the compiler will generate correctly without anything explicit.
+
+        * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
+        (WebCore::CDMFactoryClearKey::createCDM): Use std::make_unique instead of std::unique_ptr/new.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Use
+        std::make_unique instead of calling a create function.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC): Ditto.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC): Ditto.
+
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h: Made the constructor
+        public and got rid of the create function.
+        * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm:
+        (WebCore::VideoFullscreenLayerManager::create): Deleted.
+
+        * rendering/GridTrackSizingAlgorithm.cpp:
+        (WebCore::GridTrackSizingAlgorithm::computeFlexFactorUnitSize const):
+        Use std::make_unique instead of std::unique_ptr/new.
+
 2018-02-15  Andy Estes  <[email protected]>
 
         Finish unifying Apple Pay and Payment Request sources

Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (228527 => 228528)


--- trunk/Source/WebCore/loader/LinkLoader.cpp	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp	2018-02-15 19:49:24 UTC (rev 228528)
@@ -139,22 +139,22 @@
 {
     switch (resource.type()) {
     case CachedResource::ImageResource:
-        return LinkPreloadImageResourceClient::create(loader, downcast<CachedImage>(resource));
+        return std::make_unique<LinkPreloadImageResourceClient>(loader, downcast<CachedImage>(resource));
     case CachedResource::Script:
-        return LinkPreloadDefaultResourceClient::create(loader, downcast<CachedScript>(resource));
+        return std::make_unique<LinkPreloadDefaultResourceClient>(loader, downcast<CachedScript>(resource));
     case CachedResource::CSSStyleSheet:
-        return LinkPreloadStyleResourceClient::create(loader, downcast<CachedCSSStyleSheet>(resource));
+        return std::make_unique<LinkPreloadStyleResourceClient>(loader, downcast<CachedCSSStyleSheet>(resource));
     case CachedResource::FontResource:
-        return LinkPreloadFontResourceClient::create(loader, downcast<CachedFont>(resource));
+        return std::make_unique<LinkPreloadFontResourceClient>(loader, downcast<CachedFont>(resource));
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
-        return LinkPreloadDefaultResourceClient::create(loader, downcast<CachedTextTrack>(resource));
+        return std::make_unique<LinkPreloadDefaultResourceClient>(loader, downcast<CachedTextTrack>(resource));
 #endif
     case CachedResource::MediaResource:
         ASSERT(RuntimeEnabledFeatures::sharedFeatures().mediaPreloadingEnabled());
         FALLTHROUGH;
     case CachedResource::RawResource:
-        return LinkPreloadRawResourceClient::create(loader, downcast<CachedRawResource>(resource));
+        return std::make_unique<LinkPreloadRawResourceClient>(loader, downcast<CachedRawResource>(resource));
     case CachedResource::MainResource:
     case CachedResource::Icon:
 #if ENABLE(SVG_FONTS)

Modified: trunk/Source/WebCore/loader/LinkPreloadResourceClients.h (228527 => 228528)


--- trunk/Source/WebCore/loader/LinkPreloadResourceClients.h	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/loader/LinkPreloadResourceClients.h	2018-02-15 19:49:24 UTC (rev 228528)
@@ -53,7 +53,6 @@
     virtual void clear() = 0;
 
 protected:
-
     LinkPreloadResourceClient(LinkLoader&, CachedResource&);
 
     void addResource(CachedResourceClient& client)
@@ -77,46 +76,30 @@
     CachedResourceHandle<CachedResource> m_resource;
 };
 
-class LinkPreloadDefaultResourceClient: public LinkPreloadResourceClient, CachedResourceClient {
+class LinkPreloadDefaultResourceClient : public LinkPreloadResourceClient, CachedResourceClient {
 public:
-    static std::unique_ptr<LinkPreloadDefaultResourceClient> create(LinkLoader& loader, CachedScript& resource)
-    {
-        return std::unique_ptr<LinkPreloadDefaultResourceClient>(new LinkPreloadDefaultResourceClient(loader, resource));
-    }
-
-#if ENABLE(VIDEO_TRACK)
-    static std::unique_ptr<LinkPreloadDefaultResourceClient> create(LinkLoader& loader, CachedTextTrack& resource)
-    {
-        return std::unique_ptr<LinkPreloadDefaultResourceClient>(new LinkPreloadDefaultResourceClient(loader, resource));
-    }
-#endif
-
-    virtual ~LinkPreloadDefaultResourceClient() = default;
-
-
-    void notifyFinished(CachedResource& resource) override { triggerEvents(resource); }
-
-    void clear() override { clearResource(*this); }
-    bool shouldMarkAsReferenced() const override { return false; }
-
-private:
     LinkPreloadDefaultResourceClient(LinkLoader& loader, CachedResource& resource)
         : LinkPreloadResourceClient(loader, resource)
     {
         addResource(*this);
     }
+
+private:
+    void notifyFinished(CachedResource& resource) final { triggerEvents(resource); }
+    void clear() final { clearResource(*this); }
+    bool shouldMarkAsReferenced() const final { return false; }
 };
 
-class LinkPreloadStyleResourceClient: public LinkPreloadResourceClient, public CachedStyleSheetClient {
+class LinkPreloadStyleResourceClient : public LinkPreloadResourceClient, public CachedStyleSheetClient {
 public:
-    static std::unique_ptr<LinkPreloadStyleResourceClient> create(LinkLoader& loader, CachedCSSStyleSheet& resource)
+    LinkPreloadStyleResourceClient(LinkLoader& loader, CachedCSSStyleSheet& resource)
+        : LinkPreloadResourceClient(loader, resource)
     {
-        return std::unique_ptr<LinkPreloadStyleResourceClient>(new LinkPreloadStyleResourceClient(loader, resource));
+        addResource(*this);
     }
 
-    virtual ~LinkPreloadStyleResourceClient() = default;
-
-    void setCSSStyleSheet(const String&, const URL&, const String&, const CachedCSSStyleSheet* resource) override
+private:
+    void setCSSStyleSheet(const String&, const URL&, const String&, const CachedCSSStyleSheet* resource) final
     {
         ASSERT(resource);
         ASSERT(ownedResource() == resource);
@@ -123,85 +106,55 @@
         triggerEvents(*resource);
     }
 
-    void clear() override { clearResource(*this); }
-    bool shouldMarkAsReferenced() const override { return false; }
-
-private:
-    LinkPreloadStyleResourceClient(LinkLoader& loader, CachedCSSStyleSheet& resource)
-        : LinkPreloadResourceClient(loader, resource)
-    {
-        addResource(*this);
-    }
+    void clear() final { clearResource(*this); }
+    bool shouldMarkAsReferenced() const final { return false; }
 };
 
-class LinkPreloadImageResourceClient: public LinkPreloadResourceClient, public CachedImageClient {
+class LinkPreloadImageResourceClient : public LinkPreloadResourceClient, public CachedImageClient {
 public:
-    static std::unique_ptr<LinkPreloadImageResourceClient> create(LinkLoader& loader, CachedImage& resource)
+    LinkPreloadImageResourceClient(LinkLoader& loader, CachedImage& resource)
+        : LinkPreloadResourceClient(loader, static_cast<CachedResource&>(resource))
     {
-        return std::unique_ptr<LinkPreloadImageResourceClient>(new LinkPreloadImageResourceClient(loader, resource));
+        addResource(*this);
     }
 
-    virtual ~LinkPreloadImageResourceClient() = default;
-
-    void notifyFinished(CachedResource& resource) override { triggerEvents(resource); }
-
-    void clear() override { clearResource(*this); }
-    bool shouldMarkAsReferenced() const override { return false; }
-
 private:
-    LinkPreloadImageResourceClient(LinkLoader& loader, CachedImage& resource)
-        : LinkPreloadResourceClient(loader, dynamic_cast<CachedResource&>(resource))
-    {
-        addResource(*this);
-    }
+    void notifyFinished(CachedResource& resource) final { triggerEvents(resource); }
+    void clear() final { clearResource(*this); }
+    bool shouldMarkAsReferenced() const final { return false; }
 };
 
-class LinkPreloadFontResourceClient: public LinkPreloadResourceClient, public CachedFontClient {
+class LinkPreloadFontResourceClient : public LinkPreloadResourceClient, public CachedFontClient {
 public:
-    static std::unique_ptr<LinkPreloadFontResourceClient> create(LinkLoader& loader, CachedFont& resource)
+    LinkPreloadFontResourceClient(LinkLoader& loader, CachedFont& resource)
+        : LinkPreloadResourceClient(loader, resource)
     {
-        return std::unique_ptr<LinkPreloadFontResourceClient>(new LinkPreloadFontResourceClient(loader, resource));
+        addResource(*this);
     }
 
-    virtual ~LinkPreloadFontResourceClient() = default;
-
-    void fontLoaded(CachedFont& resource) override
+private:
+    void fontLoaded(CachedFont& resource) final
     {
         ASSERT(ownedResource() == &resource);
         triggerEvents(resource);
     }
 
-    void clear() override { clearResource(*this); }
-    bool shouldMarkAsReferenced() const override { return false; }
-
-private:
-    LinkPreloadFontResourceClient(LinkLoader& loader, CachedFont& resource)
-        : LinkPreloadResourceClient(loader, resource)
-    {
-        addResource(*this);
-    }
+    void clear() final { clearResource(*this); }
+    bool shouldMarkAsReferenced() const final { return false; }
 };
 
-class LinkPreloadRawResourceClient: public LinkPreloadResourceClient, public CachedRawResourceClient {
+class LinkPreloadRawResourceClient : public LinkPreloadResourceClient, public CachedRawResourceClient {
 public:
-    static std::unique_ptr<LinkPreloadRawResourceClient> create(LinkLoader& loader, CachedRawResource& resource)
-    {
-        return std::unique_ptr<LinkPreloadRawResourceClient>(new LinkPreloadRawResourceClient(loader, resource));
-    }
-
-    virtual ~LinkPreloadRawResourceClient() = default;
-
-    void notifyFinished(CachedResource& resource) override { triggerEvents(resource); }
-
-    void clear() override { clearResource(*this); }
-    bool shouldMarkAsReferenced() const override { return false; }
-
-private:
     LinkPreloadRawResourceClient(LinkLoader& loader, CachedRawResource& resource)
         : LinkPreloadResourceClient(loader, resource)
     {
         addResource(*this);
     }
+
+private:
+    void notifyFinished(CachedResource& resource) final { triggerEvents(resource); }
+    void clear() final { clearResource(*this); }
+    bool shouldMarkAsReferenced() const final { return false; }
 };
 
 }

Modified: trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp (228527 => 228528)


--- trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp	2018-02-15 19:49:24 UTC (rev 228528)
@@ -279,7 +279,7 @@
 #else
     ASSERT(supportsKeySystem(keySystem));
 #endif
-    return std::unique_ptr<CDMPrivate>(new CDMPrivateClearKey);
+    return std::make_unique<CDMPrivateClearKey>();
 }
 
 bool CDMFactoryClearKey::supportsKeySystem(const String& keySystem)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (228527 => 228528)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2018-02-15 19:49:24 UTC (rev 228528)
@@ -486,7 +486,7 @@
 MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
     : MediaPlayerPrivateAVFoundation(player)
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-    , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
+    , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManager>())
     , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
 #endif
     , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithCallback:this]))

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (228527 => 228528)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2018-02-15 19:49:24 UTC (rev 228528)
@@ -135,7 +135,7 @@
     , m_seeking(false)
     , m_loadingProgressed(false)
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
-    , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
+    , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManager>())
 #endif
 {
     CMTimebaseRef timebase = [m_synchronizer timebase];

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (228527 => 228528)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2018-02-15 19:49:24 UTC (rev 228528)
@@ -192,7 +192,7 @@
     , m_statusChangeListener(adoptNS([[WebAVSampleBufferStatusChangeListener alloc] initWithParent:this]))
     , m_clock(PAL::Clock::create())
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-    , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
+    , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManager>())
 #endif
 #if !RELEASE_LOG_DISABLED
     , m_logger(player->mediaPlayerLogger())

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h (228527 => 228528)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.h	2018-02-15 19:49:24 UTC (rev 228528)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef VideoFullscreenLayerManager_h
-#define VideoFullscreenLayerManager_h
+#pragma once
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
 
@@ -40,7 +39,7 @@
 class VideoFullscreenLayerManager {
     WTF_MAKE_NONCOPYABLE(VideoFullscreenLayerManager);
 public:
-    static std::unique_ptr<VideoFullscreenLayerManager> create();
+    VideoFullscreenLayerManager();
 
     PlatformLayer *videoInlineLayer() const { return m_videoInlineLayer.get(); }
     PlatformLayer *videoFullscreenLayer() const { return m_videoFullscreenLayer.get(); }
@@ -51,8 +50,6 @@
     void didDestroyVideoLayer();
 
 private:
-    VideoFullscreenLayerManager();
-
     RetainPtr<PlatformLayer> m_videoInlineLayer;
     RetainPtr<PlatformLayer> m_videoFullscreenLayer;
     RetainPtr<PlatformLayer> m_videoLayer;
@@ -62,5 +59,3 @@
 }
 
 #endif // PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
-
-#endif /* VideoFullscreenLayerManager_h */

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm (228527 => 228528)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm	2018-02-15 19:49:24 UTC (rev 228528)
@@ -59,11 +59,6 @@
 
 namespace WebCore {
 
-std::unique_ptr<VideoFullscreenLayerManager> VideoFullscreenLayerManager::create()
-{
-    return std::unique_ptr<VideoFullscreenLayerManager>(new VideoFullscreenLayerManager());
-}
-
 VideoFullscreenLayerManager::VideoFullscreenLayerManager()
 {
 }

Modified: trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp (228527 => 228528)


--- trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp	2018-02-15 19:47:46 UTC (rev 228527)
+++ trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp	2018-02-15 19:49:24 UTC (rev 228528)
@@ -639,7 +639,7 @@
             leftOverSpace -= baseSize;
             flexFactorSum -= flexFactor;
             if (!tracksToTreatAsInflexible)
-                tracksToTreatAsInflexible = std::unique_ptr<TrackIndexSet>(new TrackIndexSet());
+                tracksToTreatAsInflexible = std::make_unique<TrackIndexSet>();
             tracksToTreatAsInflexible->add(index);
             validFlexFactorUnit = false;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to