Bug 1272398 - use UniquePtr instead of nsAutoPtr for {Layer,LayerData}::RemoveUserData return type; r=jrmuizel
authorNathan Froyd <froydnj@gmail.com>
Tue, 24 May 2016 18:17:27 -0400
changeset 337779 bece6d2a5793234b26afab6c1217ecffa3a2f1b2
parent 337778 fd50e33b4e9b825b4634fc79db5631defa3b88b7
child 337780 7ce4920b0faff60e0731abfccbe4b486c668b9de
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1272398
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1272398 - use UniquePtr instead of nsAutoPtr for {Layer,LayerData}::RemoveUserData return type; r=jrmuizel
gfx/layers/Layers.cpp
gfx/layers/Layers.h
gfx/tests/gtest/TestLayers.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -214,20 +214,20 @@ LayerManager::AreComponentAlphaLayersEna
 }
 
 /*static*/ void
 LayerManager::LayerUserDataDestroy(void* data)
 {
   delete static_cast<LayerUserData*>(data);
 }
 
-nsAutoPtr<LayerUserData>
+UniquePtr<LayerUserData>
 LayerManager::RemoveUserData(void* aKey)
 {
-  nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
+  UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
   return d;
 }
 
 //--------------------------------------------------
 // Layer
 
 Layer::Layer(LayerManager* aManager, void* aImplData) :
   mManager(aManager),
@@ -2143,20 +2143,20 @@ Layer::IsBackfaceHidden()
         return container->GetEffectiveTransform().IsBackfaceVisible();
       }
       return container->GetBaseTransform().IsBackfaceVisible();
     }
   }
   return false;
 }
 
-nsAutoPtr<LayerUserData>
+UniquePtr<LayerUserData>
 Layer::RemoveUserData(void* aKey)
 {
-  nsAutoPtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
+  UniquePtr<LayerUserData> d(static_cast<LayerUserData*>(mUserData.Remove(static_cast<gfx::UserDataKey*>(aKey))));
   return d;
 }
 
 void
 PaintedLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
 {
   Layer::PrintInfo(aStream, aPrefix);
   if (!mValidRegion.IsEmpty()) {
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -500,17 +500,17 @@ public:
    */
   void SetUserData(void* aKey, LayerUserData* aData)
   {
     mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerUserDataDestroy);
   }
   /**
    * This can be used anytime. Ownership passes to the caller!
    */
-  nsAutoPtr<LayerUserData> RemoveUserData(void* aKey);
+  UniquePtr<LayerUserData> RemoveUserData(void* aKey);
 
   /**
    * This getter can be used anytime.
    */
   bool HasUserData(void* aKey)
   {
     return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
   }
@@ -1457,17 +1457,17 @@ public:
    */
   void SetUserData(void* aKey, LayerUserData* aData)
   {
     mUserData.Add(static_cast<gfx::UserDataKey*>(aKey), aData, LayerManager::LayerUserDataDestroy);
   }
   /**
    * This can be used anytime. Ownership passes to the caller!
    */
-  nsAutoPtr<LayerUserData> RemoveUserData(void* aKey);
+  UniquePtr<LayerUserData> RemoveUserData(void* aKey);
   /**
    * This getter can be used anytime.
    */
   bool HasUserData(void* aKey)
   {
     return mUserData.Has(static_cast<gfx::UserDataKey*>(aKey));
   }
   /**
--- a/gfx/tests/gtest/TestLayers.cpp
+++ b/gfx/tests/gtest/TestLayers.cpp
@@ -145,19 +145,19 @@ TEST(Layers, UserData) {
   TestUserData* data2 = new TestUserData;
   TestUserData* data3 = new TestUserData;
 
   layer.SetUserData(key1, data1);
   layer.SetUserData(key2, data2);
   layer.SetUserData(key3, data3);
 
   // Also checking that the user data is returned but not free'd
-  UniquePtr<LayerUserData> d1(layer.RemoveUserData(key1).forget());
-  UniquePtr<LayerUserData> d2(layer.RemoveUserData(key2).forget());
-  UniquePtr<LayerUserData> d3(layer.RemoveUserData(key3).forget());
+  UniquePtr<LayerUserData> d1(layer.RemoveUserData(key1));
+  UniquePtr<LayerUserData> d2(layer.RemoveUserData(key2));
+  UniquePtr<LayerUserData> d3(layer.RemoveUserData(key3));
   ASSERT_EQ(data1, d1.get());
   ASSERT_EQ(data2, d2.get());
   ASSERT_EQ(data3, d3.get());
 
   layer.SetUserData(key1, d1.release());
   layer.SetUserData(key2, d2.release());
   layer.SetUserData(key3, d3.release());