Bug 756813: Prevent creation of ImageLayer if ImageContainer is null r=gal
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 21 May 2012 10:47:40 -0700
changeset 94500 1aaec6842f6fc24d93fef020b8f500a04d539954
parent 94499 595b826d6d3ac29cdbbdbd62b367ce4531c39d3f
child 94501 b4e62a1e9809ed294cd0e797407992f3d000eba4
push id9641
push userdzbarsky@gmail.com
push dateMon, 21 May 2012 17:48:01 +0000
treeherdermozilla-inbound@1aaec6842f6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal
bugs756813
milestone15.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 756813: Prevent creation of ImageLayer if ImageContainer is null r=gal
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1124,33 +1124,39 @@ nsDisplayBackground::TryOptimizeToImageL
     nsCSSRendering::PrepareBackgroundLayer(presContext,
                                            mFrame,
                                            flags,
                                            borderArea,
                                            borderArea,
                                            *bg,
                                            layer);
 
+  nsImageRenderer* imageRenderer = &state.mImageRenderer;
   // We only care about images here, not gradients.
-  if (!state.mImageRenderer.IsRasterImage())
+  if (imageRenderer->IsRasterImage())
+    return false;
+
+  nsRefPtr<ImageContainer> imageContainer = imageRenderer->GetContainer();
+  // Image is not ready to be made into a layer yet
+  if (!imageContainer)
     return false;
 
   // We currently can't handle tiled or partial backgrounds.
   if (!state.mDestArea.IsEqualEdges(state.mFillArea)) {
     return false;
   }
 
   // Sub-pixel alignment is hard, lets punt on that.
   if (state.mAnchor != nsPoint(0.0f, 0.0f)) {
     return false;
   }
 
   PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
   mDestRect = nsLayoutUtils::RectToGfxRect(state.mDestArea, appUnitsPerDevPixel);
-  mImageContainer = state.mImageRenderer.GetContainer();
+  mImageContainer = imageContainer;
 
   // Ok, we can turn this into a layer if needed.
   return true;
 }
 
 LayerState
 nsDisplayBackground::GetLayerState(nsDisplayListBuilder* aBuilder,
                                    LayerManager* aManager,