bug 1028134 - Remove dangerous public destructor of gfxContext. r=bjacob
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -18,59 +18,47 @@
#include "nsAutoPtr.h"
#include "mozilla/gfx/2D.h"
typedef struct _cairo cairo_t;
struct GlyphBufferAzure;
template <typename T> class FallibleTArray;
-class gfxContext;
-
-namespace mozilla {
-template<>
-struct HasDangerousPublicDestructor<gfxContext>
-{
- static const bool value = true;
-};
-}
-
/**
* This is the main class for doing actual drawing. It is initialized using
* a surface and can be drawn on. It manages various state information like
* a current transformation matrix (CTM), a current path, current color,
* etc.
*
* All drawing happens by creating a path and then stroking or filling it.
* The functions like Rectangle and Arc do not do any drawing themselves.
* When a path is drawn (stroked or filled), it is filled/stroked with a
* pattern set by SetPattern, SetColor or SetSource.
*
* Note that the gfxContext takes coordinates in device pixels,
* as opposed to app units.
*/
-class gfxContext {
+class gfxContext MOZ_FINAL {
NS_INLINE_DECL_REFCOUNTING(gfxContext)
public:
/**
* Initialize this context from a surface.
*/
gfxContext(gfxASurface *surface);
/**
* Initialize this context from a DrawTarget.
* Strips any transform from aTarget.
* aTarget will be flushed in the gfxContext's destructor.
*/
gfxContext(mozilla::gfx::DrawTarget *aTarget,
const mozilla::gfx::Point& aDeviceOffset = mozilla::gfx::Point());
- ~gfxContext();
-
/**
* Create a new gfxContext wrapping aTarget and preserving aTarget's
* transform. Note that the transform is moved from aTarget to the resulting
* gfxContext, aTarget will no longer have its transform.
*/
static already_AddRefed<gfxContext> ContextForDrawTarget(mozilla::gfx::DrawTarget* aTarget);
/**
@@ -725,16 +713,18 @@ public:
* Copy a PNG encoded Data URL to the clipboard.
*/
void CopyAsDataURL();
#endif
static mozilla::gfx::UserDataKey sDontUseAsSourceKey;
private:
+ ~gfxContext();
+
friend class GeneralPattern;
friend struct GlyphBufferAzure;
typedef mozilla::gfx::Matrix Matrix;
typedef mozilla::gfx::DrawTarget DrawTarget;
typedef mozilla::gfx::Color Color;
typedef mozilla::gfx::StrokeOptions StrokeOptions;
typedef mozilla::gfx::Float Float;
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -120,19 +120,19 @@ gfxPlatformGtk::CreateOffscreenSurface(c
newSurface = new gfxImageSurface(ThebesIntSize(size), imageFormat);
}
if (newSurface->CairoStatus()) {
newSurface = nullptr; // surface isn't valid for some reason
}
if (newSurface && needsClear) {
- gfxContext tmpCtx(newSurface);
- tmpCtx.SetOperator(gfxContext::OPERATOR_CLEAR);
- tmpCtx.Paint();
+ nsRefPtr<gfxContext> tmpCtx = new gfxContext(newSurface);
+ tmpCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
+ tmpCtx->Paint();
}
return newSurface.forget();
}
nsresult
gfxPlatformGtk::GetFontList(nsIAtom *aLangGroup,
const nsACString& aGenericFamily,