Bug 1366984 - Fix image container check for background image layer. r=mattwoodrow
authorEthan Lin <ethlin@mozilla.com>
Wed, 31 May 2017 14:01:28 +0800
changeset 409692 5ca156581096a84c3313d5b4716c61ddc027b907
parent 409691 118e1c11be5cb1cd4fb5a3222dd8f9e11991aca0
child 409693 94906c37940c6b1c371dc7c22ed2098face96d8b
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1366984
milestone55.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 1366984 - Fix image container check for background image layer. r=mattwoodrow
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1964,33 +1964,42 @@ nsCSSRendering::CanBuildWebRenderDisplay
     nsITheme *theme = aPresCtx.GetTheme();
     if (theme && theme->ThemeSupportsWidget(&aPresCtx,
                                             aFrame,
                                             displayData->mAppearance)) {
       return false;
     }
   }
 
+  // We only support painting gradients and image for a single style image layer
   const nsStyleImage* styleImage = &aBackgroundStyle->mImage.mLayers[aLayer].mImage;
-
-  // We only support image with image container.
-  if (!styleImage->IsEmpty() && styleImage->GetType() == eStyleImageType_Image) {
+  if (styleImage->GetType() == eStyleImageType_Image) {
+    if (styleImage->GetCropRect()) {
+      return false;
+    }
+
     imgRequestProxy* requestProxy = styleImage->GetImageData();
-    if (requestProxy) {
-      nsCOMPtr<imgIContainer> srcImage;
-      requestProxy->GetImage(getter_AddRefs(srcImage));
-      if (srcImage && !srcImage->IsImageContainerAvailable(aManager, imgIContainer::FLAG_NONE)) {
-        return false;
-      }
+    if (!requestProxy) {
+      return false;
+    }
+
+    nsCOMPtr<imgIContainer> srcImage;
+    requestProxy->GetImage(getter_AddRefs(srcImage));
+    if (!srcImage || !srcImage->IsImageContainerAvailable(aManager, imgIContainer::FLAG_NONE)) {
+      return false;
     }
+
+    return true;
   }
 
-  // We only support painting gradients and image for a single style image layer
-  return styleImage->GetType() == eStyleImageType_Gradient ||
-         styleImage->GetType() == eStyleImageType_Image;
+  if (styleImage->GetType() == eStyleImageType_Gradient) {
+    return true;
+  }
+
+  return false;
 }
 
 DrawResult
 nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
                                                              mozilla::wr::DisplayListBuilder& aBuilder,
                                                              const mozilla::layers::StackingContextHelper& aSc,
                                                              nsTArray<WebRenderParentCommand>& aParentCommands,
                                                              mozilla::layers::WebRenderDisplayItemLayer* aLayer)