Fixing bug 836173. Stop leaking gfxPattern objects when using SVG with cairo. r=jwatt
authorJohnny Stenback <jst@mozilla.com>
Wed, 30 Jan 2013 01:40:34 -0800
changeset 130260 7cd7a9bc640666ff805f71fb0de12021576861df
parent 130259 e93f506bc784b4f07071dad621dd905264fc9117
child 130261 9fe869a7391ee5d84e183d9b6039ab2f03949232
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs836173
milestone21.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
Fixing bug 836173. Stop leaking gfxPattern objects when using SVG with cairo. r=jwatt
layout/svg/nsSVGGlyphFrame.cpp
--- a/layout/svg/nsSVGGlyphFrame.cpp
+++ b/layout/svg/nsSVGGlyphFrame.cpp
@@ -1041,20 +1041,23 @@ nsSVGGlyphFrame::SetupInheritablePaint(g
   } else if (SetupObjectPaint(aContext, aFillOrStroke, aOpacity, aOuterObjectPaint)) {
     aTargetPaint.SetObjectPaint(aOuterObjectPaint, (style->*aFillOrStroke).mType);
   } else {
     nscolor color = nsSVGUtils::GetFallbackOrPaintColor(aContext,
                                                         GetStyleContext(),
                                                         aFillOrStroke);
     aTargetPaint.SetColor(color);
 
-    aContext->SetPattern(new gfxPattern(gfxRGBA(NS_GET_R(color) / 255.0,
-                                                NS_GET_G(color) / 255.0,
-                                                NS_GET_B(color) / 255.0,
-                                                NS_GET_A(color) / 255.0 * aOpacity)));
+    nsRefPtr<gfxPattern> pattern =
+      new gfxPattern(gfxRGBA(NS_GET_R(color) / 255.0,
+                             NS_GET_G(color) / 255.0,
+                             NS_GET_B(color) / 255.0,
+                             NS_GET_A(color) / 255.0 * aOpacity));
+
+    aContext->SetPattern(pattern);
   }
 }
 
 bool
 nsSVGGlyphFrame::SetupObjectPaint(gfxContext *aContext,
                                   nsStyleSVGPaint nsStyleSVG::*aFillOrStroke,
                                   float& aOpacity,
                                   gfxTextObjectPaint *aOuterObjectPaint)