Bug 1358690, part 1 - Allow SVGImageContext::MaybeInitAndStoreContextPaint to be passed an existing SVGImageContext. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Tue, 28 Mar 2017 11:43:15 +0100
changeset 354692 7fac9e40baed2f483c03781e9fc0c2bbe8f32adb
parent 354690 85427dbc69bda7c9ec30cc4f1b829562ddc68f41
child 354693 09e2135b234e641e700485c872bf1d5afde1e0d0
push id31710
push usercbook@mozilla.com
push dateTue, 25 Apr 2017 09:13:15 +0000
treeherdermozilla-central@ac529a874366 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1358690
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 1358690, part 1 - Allow SVGImageContext::MaybeInitAndStoreContextPaint to be passed an existing SVGImageContext. r=dholbert
layout/generic/nsImageFrame.cpp
layout/svg/SVGImageContext.cpp
layout/svg/SVGImageContext.h
layout/xul/nsImageBoxFrame.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1695,17 +1695,17 @@ nsImageFrame::PaintImage(nsRenderingCont
                                                      &anchorPoint);
 
   uint32_t flags = aFlags;
   if (mForceSyncDecoding) {
     flags |= imgIContainer::FLAG_SYNC_DECODE;
   }
 
   Maybe<SVGImageContext> svgContext;
-  SVGImageContext::MaybeInitAndStoreContextPaint(svgContext, this, aImage);
+  SVGImageContext::MaybeStoreContextPaint(svgContext, this, aImage);
 
   DrawResult result =
     nsLayoutUtils::DrawSingleImage(*aRenderingContext.ThebesContext(),
       PresContext(), aImage,
       nsLayoutUtils::GetSamplingFilterForFrame(this), dest, aDirtyRect,
       svgContext, flags, &anchorPoint);
 
   nsImageMap* map = GetImageMap();
--- a/layout/svg/SVGImageContext.cpp
+++ b/layout/svg/SVGImageContext.cpp
@@ -11,25 +11,23 @@
 #include "gfxUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsIFrame.h"
 #include "nsPresContext.h"
 
 namespace mozilla {
 
 /* static */ void
-SVGImageContext::MaybeInitAndStoreContextPaint(Maybe<SVGImageContext>& aContext,
-                                               nsIFrame* aFromFrame,
-                                               imgIContainer* aImgContainer)
+SVGImageContext::MaybeStoreContextPaint(Maybe<SVGImageContext>& aContext,
+                                        nsIFrame* aFromFrame,
+                                        imgIContainer* aImgContainer)
 {
   static bool sEnabledForContent = false;
   static bool sEnabledForContentCached = false;
 
-  MOZ_ASSERT(!aContext, "The emplace() call below with overwrite this object");
-
   if (!sEnabledForContentCached) {
     Preferences::AddBoolVarCache(&sEnabledForContent,
                                  "svg.context-properties.content.enabled", false);
     sEnabledForContentCached = true;
   }
 
   if (!sEnabledForContent &&
       !aFromFrame->PresContext()->IsChrome()) {
@@ -57,14 +55,16 @@ SVGImageContext::MaybeInitAndStoreContex
     contextPaint->SetFill(style->mFill.GetColor());
   }
   if (style->mStroke.Type() == eStyleSVGPaintType_Color) {
     haveContextPaint = true;
     contextPaint->SetStroke(style->mStroke.GetColor());
   }
 
   if (haveContextPaint) {
-    aContext.emplace();
+    if (!aContext) {
+      aContext.emplace();
+    }
     aContext->mContextPaint = contextPaint.forget();
   }
 }
 
 } // namespace mozilla
--- a/layout/svg/SVGImageContext.h
+++ b/layout/svg/SVGImageContext.h
@@ -42,19 +42,19 @@ public:
    * that utility and stop using Maybe for this parameter.
    */
   explicit SVGImageContext(const Maybe<CSSIntSize>& aViewportSize,
                            const Maybe<SVGPreserveAspectRatio>& aPreserveAspectRatio  = Nothing())
     : mViewportSize(aViewportSize)
     , mPreserveAspectRatio(aPreserveAspectRatio)
   { }
 
-  static void MaybeInitAndStoreContextPaint(Maybe<SVGImageContext>& aContext,
-                                            nsIFrame* aFromFrame,
-                                            imgIContainer* aImgContainer);
+  static void MaybeStoreContextPaint(Maybe<SVGImageContext>& aContext,
+                                     nsIFrame* aFromFrame,
+                                     imgIContainer* aImgContainer);
 
   const Maybe<CSSIntSize>& GetViewportSize() const {
     return mViewportSize;
   }
 
   void SetViewportSize(const Maybe<CSSIntSize>& aSize) {
     mViewportSize = aSize;
   }
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -405,17 +405,17 @@ nsImageBoxFrame::PaintImage(nsRenderingC
     dest = nsLayoutUtils::ComputeObjectDestRect(constraintRect,
                                                 intrinsicSize,
                                                 intrinsicRatio,
                                                 StylePosition(),
                                                 anchorPoint.ptr());
   }
 
   Maybe<SVGImageContext> svgContext;
-  SVGImageContext::MaybeInitAndStoreContextPaint(svgContext, this, imgCon);
+  SVGImageContext::MaybeStoreContextPaint(svgContext, this, imgCon);
 
   return nsLayoutUtils::DrawSingleImage(
            *aRenderingContext.ThebesContext(),
            PresContext(), imgCon,
            nsLayoutUtils::GetSamplingFilterForFrame(this),
            dest, dirty,
            svgContext, aFlags,
            anchorPoint.ptrOr(nullptr),