Bug 1601775. Stop needlessly calling PMPrintSettingsSetJobName in nsPrintDialogServiceX::Show. r=mstange

We want the print job title set when actually submitting the job to a printer
so that the job appears with a useful title in any print job management
software the user may be using. However, we do that in
nsDeviceContextSpecX::BeginDocument, which is the place that it needs to
happen.

This removed code is called much earlier, while setting up to open the print
dialog and using a temporary nsPrintSettingsX in order to configure the
dialog. The dialog does not make use of the print job name (and we discard
the nsPrintSettingsX before going on to do the print using BeginDocument).

This removes the last piece of code that requires us to pass a
nsIWebBrowserPrint to the print dialog opening code. Removing that clears the
way to simplify the code and get printing working with Fission enabled.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Watt 2019-12-05 22:19:46 +00:00
Родитель cb2643c22d
Коммит 8243aa8de2
3 изменённых файлов: 0 добавлений и 43 удалений

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

@ -51,23 +51,6 @@ nsPrintDialogServiceX::Show(nsPIDOMWindowOuter* aParent, nsIPrintSettings* aSett
// name to be set. // name to be set.
settingsX->SetPrinterNameFromPrintInfo(); settingsX->SetPrinterNameFromPrintInfo();
printSettingsSvc->InitPrintSettingsFromPrefs(settingsX, true, nsIPrintSettings::kInitSaveAll); printSettingsSvc->InitPrintSettingsFromPrefs(settingsX, true, nsIPrintSettings::kInitSaveAll);
// Set the print job title
nsAutoString docName;
nsresult rv = aWebBrowserPrint->GetDocumentName(docName);
if (NS_SUCCEEDED(rv)) {
// Print Core of Application Service sent print job with names exceeding
// 255 bytes. This is a workaround until fix it.
// (https://openradar.appspot.com/34428043)
nsAutoString adjustedTitle;
PrintTarget::AdjustPrintJobNameForIPP(docName, adjustedTitle);
CFStringRef cfTitleString = CFStringCreateWithCharacters(
NULL, reinterpret_cast<const UniChar*>(adjustedTitle.BeginReading()),
adjustedTitle.Length());
if (cfTitleString) {
::PMPrintSettingsSetJobName(settingsX->GetPMPrintSettings(), cfTitleString);
CFRelease(cfTitleString);
}
}
NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo(); NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();

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

@ -43,11 +43,6 @@ class nsPrintSettingsServiceX final : public nsPrintSettingsService {
nsresult _CreatePrintSettings(nsIPrintSettings** _retval) override; nsresult _CreatePrintSettings(nsIPrintSettings** _retval) override;
private: private:
/* Serialization done in child to be deserialized in the parent */
nsresult SerializeToPrintDataChild(nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWBP,
mozilla::embedding::PrintData* data);
/* Serialization done in parent to be deserialized in the child */ /* Serialization done in parent to be deserialized in the child */
nsresult SerializeToPrintDataParent(nsIPrintSettings* aSettings, nsresult SerializeToPrintDataParent(nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWBP, nsIWebBrowserPrint* aWBP,

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

@ -35,27 +35,6 @@ nsPrintSettingsServiceX::SerializeToPrintData(nsIPrintSettings* aSettings, nsIWe
return SerializeToPrintDataParent(aSettings, aWBP, data); return SerializeToPrintDataParent(aSettings, aWBP, data);
} }
return SerializeToPrintDataChild(aSettings, aWBP, data);
}
nsresult nsPrintSettingsServiceX::SerializeToPrintDataChild(nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWBP,
PrintData* data) {
// If we are in the child process, we don't need to populate
// nsPrintSettingsX completely. The parent discards almost all of
// this data (bug 1328975). Furthermore, reading some of the
// printer/printing settings from the OS causes a connection to the
// printer to be made which is blocked by sandboxing and results in hangs.
if (aWBP) {
// When serializing an nsIWebBrowserPrint, we need to pass up the
// document name.
nsAutoString docName;
nsresult rv = aWBP->GetDocumentName(docName);
if (NS_SUCCEEDED(rv)) {
data->printJobName().Assign(docName.get());
}
}
return NS_OK; return NS_OK;
} }