Bug 971678 - Validate the compositable type in SetCompositableHost - r=nical
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 20 Feb 2014 15:07:04 -0500
changeset 170102 11e06d77e4f9720f702965fdcd7fb09c1ba57392
parent 170101 3bfe9190b72d40b956bd99600ea3d940d843b8db
child 170103 557fa51454b8412301391ecf5c41acfc9a14befa
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersnical
bugs971678
milestone30.0a1
Bug 971678 - Validate the compositable type in SetCompositableHost - r=nical
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/ImageLayerComposite.cpp
gfx/layers/composite/ThebesLayerComposite.cpp
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -38,18 +38,26 @@ CanvasLayerComposite::~CanvasLayerCompos
   MOZ_COUNT_DTOR(CanvasLayerComposite);
 
   CleanupResources();
 }
 
 bool
 CanvasLayerComposite::SetCompositableHost(CompositableHost* aHost)
 {
-  mImageHost = aHost;
-  return true;
+  switch (aHost->GetType()) {
+    case BUFFER_IMAGE_SINGLE:
+    case BUFFER_IMAGE_BUFFERED:
+    case COMPOSITABLE_IMAGE:
+      mImageHost = aHost;
+      return true;
+    default:
+      return false;
+  }
+
 }
 
 Layer*
 CanvasLayerComposite::GetLayer()
 {
   return this;
 }
 
--- a/gfx/layers/composite/ImageLayerComposite.cpp
+++ b/gfx/layers/composite/ImageLayerComposite.cpp
@@ -45,18 +45,25 @@ ImageLayerComposite::~ImageLayerComposit
   MOZ_ASSERT(mDestroyed);
 
   CleanupResources();
 }
 
 bool
 ImageLayerComposite::SetCompositableHost(CompositableHost* aHost)
 {
-  mImageHost = aHost;
-  return true;
+  switch (aHost->GetType()) {
+    case BUFFER_IMAGE_SINGLE:
+    case BUFFER_IMAGE_BUFFERED:
+    case COMPOSITABLE_IMAGE:
+      mImageHost = aHost;
+      return true;
+    default:
+      return false;
+  }
 }
 
 void
 ImageLayerComposite::Disconnect()
 {
   Destroy();
 }
 
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -47,18 +47,28 @@ ThebesLayerComposite::~ThebesLayerCompos
 {
   MOZ_COUNT_DTOR(ThebesLayerComposite);
   CleanupResources();
 }
 
 bool
 ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost)
 {
-  mBuffer = static_cast<ContentHost*>(aHost);
-  return true;
+  switch (aHost->GetType()) {
+    case BUFFER_CONTENT:
+    case BUFFER_CONTENT_DIRECT:
+    case BUFFER_CONTENT_INC:
+    case BUFFER_TILED:
+    case COMPOSITABLE_CONTENT_SINGLE:
+    case COMPOSITABLE_CONTENT_DOUBLE:
+      mBuffer = static_cast<ContentHost*>(aHost);
+      return true;
+    default:
+      return false;
+  }
 }
 
 void
 ThebesLayerComposite::Disconnect()
 {
   Destroy();
 }