diff --git a/widget/cocoa/nsDeviceContextSpecX.mm b/widget/cocoa/nsDeviceContextSpecX.mm index 797e834250c2..4724fc72b26b 100644 --- a/widget/cocoa/nsDeviceContextSpecX.mm +++ b/widget/cocoa/nsDeviceContextSpecX.mm @@ -47,19 +47,14 @@ static LazyLogModule sDeviceContextSpecXLog("DeviceContextSpecX"); NS_IMPL_ISUPPORTS(nsPrinterListX, nsIPrinterList); NS_IMETHODIMP -nsPrinterListX::GetSystemDefaultPrinter(nsIPrinter** aDefaultPrinter) { +nsPrinterListX::GetSystemDefaultPrinterName(nsAString& aName) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; - NS_ENSURE_ARG_POINTER(aDefaultPrinter); - *aDefaultPrinter = nullptr; - + aName.Truncate(); NSArray* printerNames = [NSPrinter printerNames]; if ([printerNames count] > 0) { NSString* name = [printerNames objectAtIndex:0]; - nsAutoString printerName; - nsCocoaUtils::GetStringForNSString(name, printerName); - *aDefaultPrinter = new nsPrinter(printerName); - NS_ADDREF(*aDefaultPrinter); + nsCocoaUtils::GetStringForNSString(name, aName); return NS_OK; } diff --git a/widget/gtk/nsDeviceContextSpecG.cpp b/widget/gtk/nsDeviceContextSpecG.cpp index a8d84268d5eb..d4f0f8288998 100644 --- a/widget/gtk/nsDeviceContextSpecG.cpp +++ b/widget/gtk/nsDeviceContextSpecG.cpp @@ -372,13 +372,8 @@ nsPrinterListGTK::GetPrinters(nsTArray>& aPrinters) { } NS_IMETHODIMP -nsPrinterListGTK::GetSystemDefaultPrinter(nsIPrinter** aDefaultPrinter) { - nsAutoString printerName; - GlobalPrinters::GetInstance()->GetSystemDefaultPrinterName(printerName); - - *aDefaultPrinter = new nsPrinter(printerName); - NS_ADDREF(*aDefaultPrinter); - +nsPrinterListGTK::GetSystemDefaultPrinterName(nsAString& aName) { + GlobalPrinters::GetInstance()->GetSystemDefaultPrinterName(aName); return NS_OK; } diff --git a/widget/nsIPrinterList.idl b/widget/nsIPrinterList.idl index e1e80d220698..eb4556c60cab 100644 --- a/widget/nsIPrinterList.idl +++ b/widget/nsIPrinterList.idl @@ -23,12 +23,11 @@ interface nsIPrinterList : nsISupports in nsIPrintSettings aPrintSettings); /** - * The system default printer. This should also be - * present in printers below. This is not necessarily gecko's + * The system default printer name. This is not necessarily gecko's * default printer; see nsIPrintSettingsService.lastUsedPrinterName * for that. */ - readonly attribute nsIPrinter systemDefaultPrinter; + readonly attribute AString systemDefaultPrinterName; /** * The list of printers. diff --git a/widget/nsPrintSettingsService.cpp b/widget/nsPrintSettingsService.cpp index e188f4494c2f..921b94bd7d36 100644 --- a/widget/nsPrintSettingsService.cpp +++ b/widget/nsPrintSettingsService.cpp @@ -921,11 +921,7 @@ nsPrintSettingsService::GetLastUsedPrinterName( // There is no last printer preference, or it doesn't name a valid printer. // Return the system default from the printer list. - RefPtr defaultPrinter; - printerList->GetSystemDefaultPrinter(getter_AddRefs(defaultPrinter)); - if (defaultPrinter) { - defaultPrinter->GetName(aLastUsedPrinterName); - } + printerList->GetSystemDefaultPrinterName(aLastUsedPrinterName); return NS_OK; } diff --git a/widget/windows/nsDeviceContextSpecWin.cpp b/widget/windows/nsDeviceContextSpecWin.cpp index 6b13e5970391..a2fddff5f0d4 100644 --- a/widget/windows/nsDeviceContextSpecWin.cpp +++ b/widget/windows/nsDeviceContextSpecWin.cpp @@ -514,13 +514,8 @@ nsresult nsDeviceContextSpecWin::GetDataFromPrinter(const nsAString& aName, NS_IMPL_ISUPPORTS(nsPrinterListWin, nsIPrinterList) NS_IMETHODIMP -nsPrinterListWin::GetSystemDefaultPrinter(nsIPrinter** aDefaultPrinter) { - NS_ENSURE_ARG_POINTER(aDefaultPrinter); - *aDefaultPrinter = nullptr; - nsAutoString printerName; - GlobalPrinters::GetInstance()->GetDefaultPrinterName(printerName); - *aDefaultPrinter = new nsPrinter(printerName); - NS_ADDREF(*aDefaultPrinter); +nsPrinterListWin::GetSystemDefaultPrinterName(nsAString& aName) { + GlobalPrinters::GetInstance()->GetDefaultPrinterName(aName); return NS_OK; } diff --git a/widget/windows/nsPrintDialogUtil.cpp b/widget/windows/nsPrintDialogUtil.cpp index d2b636c83643..711f2ee94d56 100644 --- a/widget/windows/nsPrintDialogUtil.cpp +++ b/widget/windows/nsPrintDialogUtil.cpp @@ -136,14 +136,11 @@ static nsReturnRef CreateGlobalDevModeAndInit( //------------------------------------------------------------------ // helper static void GetDefaultPrinterNameFromGlobalPrinters(nsAString& aPrinterName) { + aPrinterName.Truncate(); nsCOMPtr printerList = do_GetService("@mozilla.org/gfx/printerlist;1"); if (printerList) { - nsIPrinter* printer = nullptr; - printerList->GetSystemDefaultPrinter(&printer); - if (printer) { - printer->GetName(aPrinterName); - } + printerList->GetSystemDefaultPrinterName(aPrinterName); } }