b=797568 only GetImageContainer in BuildLayer if the container will be used r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 31 Oct 2012 15:54:06 +1300
changeset 111994 caad55e54b0bc1cbb8a095b3bcbd7310b4ae2fef
parent 111993 08783347c920394857b746adb502c5391fdfbd48
child 111995 d7e77004a0d0dd5bd14c23ececf49c60c1231888
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersroc
bugs797568
milestone19.0a1
b=797568 only GetImageContainer in BuildLayer if the container will be used r=roc
layout/generic/nsObjectFrame.cpp
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -1590,24 +1590,16 @@ nsObjectFrame::BuildLayer(nsDisplayListB
   NPWindow* window = nullptr;
   mInstanceOwner->GetWindow(window);
   if (!window)
     return nullptr;
 
   if (window->width <= 0 || window->height <= 0)
     return nullptr;
 
-  // Create image
-  nsRefPtr<ImageContainer> container = mInstanceOwner->GetImageContainer();
-
-  if (!container) {
-    // This can occur if our instance is gone.
-    return nullptr;
-  }
-
   // window is in "display pixels", but size needs to be in device pixels
   double scaleFactor = 1.0;
   if (NS_FAILED(mInstanceOwner->GetContentsScaleFactor(&scaleFactor))) {
     scaleFactor = 1.0;
   }
   int intScaleFactor = ceil(scaleFactor);
   gfxIntSize size(window->width * intScaleFactor, window->height * intScaleFactor);
 
@@ -1622,18 +1614,24 @@ nsObjectFrame::BuildLayer(nsDisplayListB
     if (!layer) {
       mInstanceOwner->NotifyPaintWaiter(aBuilder);
       // Initialize ImageLayer
       layer = aManager->CreateImageLayer();
       if (!layer)
         return nullptr;
     }
 
+    // Create image
+    nsRefPtr<ImageContainer> container = mInstanceOwner->GetImageContainer();
+    if (!container) {
+      // This can occur if our instance is gone.
+      return nullptr;
+    }
+
     NS_ASSERTION(layer->GetType() == Layer::TYPE_IMAGE, "Bad layer type");
-
     ImageLayer* imglayer = static_cast<ImageLayer*>(layer.get());
     UpdateImageLayer(r);
 
     imglayer->SetScaleToSize(size, ImageLayer::SCALE_STRETCH);
     imglayer->SetContainer(container);
     gfxPattern::GraphicsFilter filter =
       nsLayoutUtils::GetGraphicsFilterForFrame(this);
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE