Bug 1346618 - Part 1. Correct opacity pass to VectorImage. draft
authorcku <cku@mozilla.com>
Sat, 18 Mar 2017 02:47:06 +0800
changeset 502124 d9f991ada75cd65e6d91ae013b66a6111ce60cd1
parent 501569 05bfa2831c0ba4a26fa72328ffe6a99aba9c356a
child 502125 e59069d389afc6587d67efb50c02becdeb0b0246
child 502173 1bb770e46b4d616d4cb9dbd1b6b929c3453b7fb9
push id50189
push userbmo:cku@mozilla.com
push dateTue, 21 Mar 2017 09:12:11 +0000
bugs1346618
milestone55.0a1
Bug 1346618 - Part 1. Correct opacity pass to VectorImage. Even we pass aOpacity(0.5) to an SVGDrawingParameters object's constructor at [1], SVGDrawingParameters::opacity will still be set as 1.0 since we also pass aSVGContext to it. As a result, SVGDrawingParameters::opacity is set by the return value of aSVGContext->GetGlobalOpacity(), which is 1.0. Fix this problem by passing opacity to SVGImageContext. [1] https://hg.mozilla.org/mozilla-central/file/588c44c7a966/image/VectorImage.cpp#l789 MozReview-Commit-ID: ByiPa4sreEh
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -6791,17 +6791,18 @@ nsLayoutUtils::DrawBackgroundImage(gfxCo
                                    const nsRect&       aDirty,
                                    uint32_t            aImageFlags,
                                    ExtendMode          aExtendMode,
                                    float               aOpacity)
 {
   PROFILER_LABEL("layout", "nsLayoutUtils::DrawBackgroundImage",
                  js::ProfileEntry::Category::GRAPHICS);
 
-  const Maybe<SVGImageContext> svgContext(Some(SVGImageContext(Some(aImageSize))));
+  const Maybe<SVGImageContext>
+    svgContext(Some(SVGImageContext(Some(aImageSize), Nothing(), aOpacity)));
 
   /* Fast path when there is no need for image spacing */
   if (aRepeatSize.width == aDest.width && aRepeatSize.height == aDest.height) {
     return DrawImageInternal(aContext, aPresContext, aImage,
                              aSamplingFilter, aDest, aFill, aAnchor,
                              aDirty, svgContext, aImageFlags, aExtendMode,
                              aOpacity);
   }