Bug 1272398 - use UniquePtr instead of nsAutoPtr for {Layer,LayerData}::RemoveUserData return type; r=jrmuizel
☠☠ backed out by c403ac05b8f4 ☠ ☠
authorNathan Froyd <froydnj@gmail.com>
Thu, 19 May 2016 21:48:59 -0400
changeset 298163 3d201ae294f8adb86423b2506c6d38854498a097
parent 298162 64031b8696dfb6230ed0e16f149694014ee98e83
child 298164 39496abed3def6af2c5342a84263d3a03c457db7
push id77050
push usernfroyd@mozilla.com
push dateThu, 19 May 2016 17:50:15 +0000
treeherdermozilla-inbound@39496abed3de [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());