Bug 370034: Replace nsIDeviceContext::GetDeviceContextFor with nsIDeviceContext::Init. r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@220196 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sharparrow1%yahoo.com
2007-02-15 11:08:47 +00:00
parent 3018041fe6
commit 8e3fe5e197
5 changed files with 41 additions and 69 deletions

View File

@@ -833,23 +833,18 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
#ifdef NS_PRINT_PREVIEW
if (mIsPageMode) {
nsCOMPtr<nsIDeviceContext> devctx;
;
nsCOMPtr<nsIDeviceContextSpec> devspec =
do_CreateInstance("@mozilla.org/gfx/devicecontextspec;1");
// XXX CRASHES ON OOM. YUM. WOULD SOMEONE PLEASE FIX ME.
// PERHAPS SOMEONE SHOULD HAVE REVIEWED THIS CODE.
// XXX I have no idea how critical this code is, so i'm not fixing it.
// In fact I'm just adding a line that makes this block
// get compiled *less* often.
do_CreateInstance("@mozilla.org/gfx/devicecontextspec;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// mWindow has been initialized by preceding call to MakeWindow
devspec->Init(mWindow, mPresContext->GetPrintSettings(), PR_FALSE);
// XXX CRASHES ON OOM under at least
// nsPrintJobFactoryPS::CreatePrintJob. WOULD SOMEONE PLEASE FIX ME.
// PERHAPS SOMEONE SHOULD HAVE REVIEWED THIS CODE.
// XXX I have no idea how critical this code is, so i'm not fixing it.
// In fact I'm just adding a line that makes this block
// get compiled *less* often.
mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(devctx));
rv = devspec->Init(mWindow, mPresContext->GetPrintSettings(), PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDeviceContext> devctx =
do_CreateInstance("@mozilla.org/gfx/devicecontext;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = devctx->Init(devspec);
NS_ENSURE_SUCCESS(rv, rv);
// XXX I'm breaking this code; I'm not sure I really want to mess with
// the document viewer at the moment to get the right device context
// (this won't break anyone, since page layout mode was never really
@@ -4093,6 +4088,9 @@ DocumentViewerImpl::OnDonePrinting()
NS_IMETHODIMP DocumentViewerImpl::SetPageMode(PRBool aPageMode, nsIPrintSettings* aPrintSettings)
{
// XXX until the print code is in a more stable state, I don't
// want to worry about this code
return NS_ERROR_NOT_IMPLEMENTED;
mIsPageMode = aPageMode;
// Get the current size of what is being viewed
nsRect bounds;