Bug 253889 - part 1: Get rid of nsIPresShell from gfx r=jwatt

`gfxUtils::WriteAsPNG()` is the only user of `nsIPresShell` in `gfx`, but
nobody calls it.  So, we can get rid of it with `nsIPresShell` reference.

Differential Revision: https://phabricator.services.mozilla.com/D29310

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-05-02 07:43:49 +00:00
Родитель 2b2dc014eb
Коммит 982428a83e
3 изменённых файлов: 1 добавлений и 22 удалений

Просмотреть файл

@ -17,10 +17,10 @@
#include "nsRefreshDriver.h" #include "nsRefreshDriver.h"
class nsIContentViewer; class nsIContentViewer;
class nsIPresShell;
class gfxSVGGlyphs; class gfxSVGGlyphs;
namespace mozilla { namespace mozilla {
class PresShell;
class SVGContextPaint; class SVGContextPaint;
namespace dom { namespace dom {
class Document; class Document;

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsIClipboardHelper.h" #include "nsIClipboardHelper.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsIGfxInfo.h" #include "nsIGfxInfo.h"
#include "nsIPresShell.h"
#include "nsMimeTypes.h" #include "nsMimeTypes.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsRegion.h" #include "nsRegion.h"
@ -1228,24 +1227,6 @@ void gfxUtils::WriteAsPNG(DrawTarget* aDT, const char* aFile) {
} }
} }
/* static */
void gfxUtils::WriteAsPNG(nsIPresShell* aShell, const char* aFile) {
int32_t width = 1000, height = 1000;
nsRect r(0, 0, aShell->GetPresContext()->DevPixelsToAppUnits(width),
aShell->GetPresContext()->DevPixelsToAppUnits(height));
RefPtr<mozilla::gfx::DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
IntSize(width, height), SurfaceFormat::B8G8R8A8);
NS_ENSURE_TRUE(dt && dt->IsValid(), /*void*/);
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context); // already checked the draw target above
aShell->RenderDocument(r, RenderDocumentFlags::None, NS_RGB(255, 255, 0),
context);
WriteAsPNG(dt.get(), aFile);
}
/* static */ /* static */
void gfxUtils::DumpAsDataURI(SourceSurface* aSurface, FILE* aFile) { void gfxUtils::DumpAsDataURI(SourceSurface* aSurface, FILE* aFile) {
EncodeSourceSurface(aSurface, ImageType::PNG, EmptyString(), eDataURIEncode, EncodeSourceSurface(aSurface, ImageType::PNG, EmptyString(), eDataURIEncode,

Просмотреть файл

@ -24,7 +24,6 @@ class gfxDrawable;
struct gfxQuad; struct gfxQuad;
class nsIInputStream; class nsIInputStream;
class nsIGfxInfo; class nsIGfxInfo;
class nsIPresShell;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -267,7 +266,6 @@ class gfxUtils {
static void WriteAsPNG(SourceSurface* aSurface, const char* aFile); static void WriteAsPNG(SourceSurface* aSurface, const char* aFile);
static void WriteAsPNG(DrawTarget* aDT, const nsAString& aFile); static void WriteAsPNG(DrawTarget* aDT, const nsAString& aFile);
static void WriteAsPNG(DrawTarget* aDT, const char* aFile); static void WriteAsPNG(DrawTarget* aDT, const char* aFile);
static void WriteAsPNG(nsIPresShell* aShell, const char* aFile);
/** /**
* Dump as a PNG encoded Data URL to a FILE stream (using stdout by * Dump as a PNG encoded Data URL to a FILE stream (using stdout by