Bug 1091112 - Print dialog doesn't get focus automatically, if e10s is enabled
Ok, this is a matter of proxying the dialog to the parent like we do with Windows and Linux.
This should also fix
Bug 1091103
- Print dialog does not use retina resolution with e10s enabled.
So here we go again. I think this is a matter of finding out what the
dialog needs, serializing it, deserializing it, big bada boom.
nsIWebBrowserPrint::enumerateDocumentNames is something I need to send over...
nsPrintDialogServiceX::Show seems to have all of the hints.
Basically, I need it so that what's deserialized can
provide enumerateDocumentNames for this:
char16_t** docTitles;
uint32_t titleCount;
nsresult rv = aWebBrowserPrint->EnumerateDocumentNames(&titleCount, &docTitles);
if (NS_SUCCEEDED(rv) && titleCount > 0) {
CFStringRef cfTitleString = CFStringCreateWithCharacters(NULL, reinterpret_cast<const UniChar*>(docTitles[0]),
NS_strlen(docTitles[0]));
if (cfTitleString) {
::PMPrintSettingsSetJobName(settingsX->GetPMPrintSettings(), cfTitleString);
CFRelease(cfTitleString);
}
for (int32_t i = titleCount - 1; i >= 0; i--) {
free(docTitles[i]);
}
free(docTitles);
docTitles = NULL;
titleCount = 0;
}
And then I also need it to be able to spew out NSPrintInfo. Yech:
NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();
So it looks like an NSPrintInfo wraps a dictionary, like GTK. So maybe I
can just extract that dictionary, send it on down to the content
process, where it'll replace the nsIPrintSettingX's NSPrintInfo with a
new one.
So let's break this down:
See if the title for nsIPrintSettings is good enough
for PMPrintSettingsSetJobName. Looks like Title and DocURL is
mostly ignored. WTF.
Serialize and send the document names over. Actually, we just need to
send one, since the first one is the only one that nsPrintDialogX
listens for.
The dictionary is keyed on NSStrings. The value can be any number of
things, I'm afraid… I see NSPrinter, NSNumber, NSString, NSDate, NSURL
When deserializing, it looks like we can get an NSPrinter back via [NSPrinter printerWithName:@"NAME"]
So I think instead of passing an array of key-value pair, I just add
fields to PPrintingTypes.ipdlh - and make sure the primitives get
initialized as empty.
NSString *const NSPrintPrinter; NSString *const NSPrintCopies;
NSString *const NSPrintAllPages; NSString *const NSPrintFirstPage;
NSString *const NSPrintLastPage; NSString *const NSPrintMustCollate;
NSString *const NSPrintReversePageOrder; NSString *const
NSPrintJobDisposition; NSString *const NSPrintSavePath; NSString *const
NSPrintPagesAcross; NSString *const NSPrintPagesDown; NSString *const
NSPrintTime; NSString *const NSPrintDetailedErrorReporting; NSString
*const NSPrintFaxNumber; NSString *const NSPrintPrinterName; NSString
*const NSPrintHeaderAndFooter; NSString *const NSPrintSelectionOnly;
NSString *const NSPrintJobSavingURL; NSString *const
NSPrintJobSavingFileNameExtensionHidden'
Constants we need to serialize
NSPrintPrinter
An NSPrinter object—the printer to use.
Available in OS X v10.0 and later.
Solution
: Store this in printerName.
NSPrintPrinterName
An NSString object that specifies the name of a printer.
Available in OS X v10.4 and later.
Solution:
Just store this in printerName.
NSPrintCopies
An NSNumber object containing an integer—the number of copies to spool.
Available in OS X v10.0 and later.
Solution:
Store this in numCopies.
NSPrintAllPages
An NSNumber object containing a Boolean value—if YES, includes all pages in output.
Available in OS X v10.0 and later.
Solution:
Add a new bool field - printAllPages.
NSPrintFirstPage
An NSNumber object containing an integer value that specifies the first page in the print job.
Available in OS X v10.0 and later.
Solution:
Store this in startPageRange
NSPrintLastPage
An NSNumber object containing an integer value that specifies the last page in the print job.
Available in OS X v10.0 and later.
Solution
: Store this in endPageRange.
NSPrintMustCollate
An NSNumber object containing a Boolean value—if YES, collates output.
Available in OS X v10.0 and later.
Solution:
Add a new bool field - mustCollate.
NSPrintReversePageOrder
An NSNumber object containing a Boolean value—if YES, prints first page last.
Available in OS X v10.0 and later.
Solution:
Store this in printReversed.
NSPrintJobDisposition
An NSString object that specifies the job disposition.
NSPrintSpoolJob, NSPrintPreviewJob, NSPrintSaveJob, or NSPrintCancelJob. See
setJobDisposition:
for details.
Available in OS X v10.0 and later.
Solution:
Add a new short field - disposition
NSPrintPagesAcross
An NSNumber object that specifies the number of logical pages to be tiled horizontally on a physical sheet of paper.
Available in OS X v10.4 and later.
Solution:
Add a new short field - pagesAcross
NSPrintPagesDown
An
NSNumber
object that specifies the number of logical pages to be tiled vertically on a physical sheet of paper.
Available in OS X v10.4 and later.
Solution:
Add a new short field - pagesDown
NSPrintDetailedErrorReporting
An NSNumber object containing a Boolean value—if YES, produce detailed reports when an error occurs.
Available in OS X v10.4 and later.
Solution:
Add a new bool field - detailedErrorReporting
NSPrintFaxNumber
An NSString object that specifies a fax number.
Available in OS X v10.4 and later.
Solution:
Add a new string field - faxNumber
NSPrintHeaderAndFooter
An NSNumber object containing a Boolean value—if YES, a standard header and footer are added outside the margins of each page.
Available in OS X v10.4 and later.
Solution:
Add a new bool field - addHeaderAndFooter.
NSPrintJobSavingFileNameExtensionHidden
A boolean NSNumber indicating whether the job’s file name extension should be hidden when the
jobDisposition
is
NSPrintSaveJob
. The default is NO.
Available in OS X v10.6 and later.
Solution:
Add a new bool field fileNameExtensionHidden
NSPrintSelectionOnly
An NSNumber object containing a Boolean value—if YES only the current selection is printed.
Available in OS X v10.6 and later.
Solution:
Store this in print options flags via nsIPrintSettings::kEnableSelectionRB. We'll need to add options to the common group.
NSPrintJobSavingURL
Available in OS X v10.6 and later.
Solution:
Store this in toFileName.
NSPrintTime
An NSDate object that specifies the time at which printing should begin.
Available in OS X v10.4 and later.
Have parent process create an nsPrintSettingsX, and hand it over to the dialog.
The thing we get back to give to the content process… make sure we serialize the NSPrintInfo dictionary.
Deserialize the document names for EnumerateDocumentNames for MockWebBrowserPrint
NSPrintPrinter
An NSPrinter object—the printer to use.
Available in OS X v10.0 and later.
Using just the printer name, I think we need to get a reference to an NSPrinter.
NSPrintPrinterName
An NSString object that specifies the name of a printer.
Available in OS X v10.4 and later.
NSPrintCopies
An NSNumber object containing an integer—the number of copies to spool.
Available in OS X v10.0 and later.
NSPrintAllPages
An NSNumber object containing a Boolean value—if YES, includes all pages in output.
Available in OS X v10.0 and later.
NSPrintFirstPage
An NSNumber object containing an integer value that specifies the first page in the print job.
Available in OS X v10.0 and later.
NSPrintLastPage
An NSNumber object containing an integer value that specifies the last page in the print job.
Available in OS X v10.0 and later.
NSPrintMustCollate
An NSNumber object containing a Boolean value—if YES, collates output.
Available in OS X v10.0 and later.
NSPrintReversePageOrder
An NSNumber object containing a Boolean value—if YES, prints first page last.
Available in OS X v10.0 and later.
NSPrintJobDisposition
An NSString object that specifies the job disposition.
NSPrintSpoolJob, NSPrintPreviewJob, NSPrintSaveJob, or NSPrintCancelJob. See
setJobDisposition:
for details.
Available in OS X v10.0 and later.
NSPrintPagesAcross
An NSNumber object that specifies the number of logical pages to be tiled horizontally on a physical sheet of paper.
Available in OS X v10.4 and later.
NSPrintPagesDown
An
NSNumber
object that specifies the number of logical pages to be tiled vertically on a physical sheet of paper.
Available in OS X v10.4 and later.
NSPrintDetailedErrorReporting
An NSNumber object containing a Boolean value—if YES, produce detailed reports when an error occurs.
Available in OS X v10.4 and later.
NSPrintFaxNumber
An NSString object that specifies a fax number.
Available in OS X v10.4 and later.
Solution:
Add a new string field - faxNumber
NSPrintHeaderAndFooter
An NSNumber object containing a Boolean value—if YES, a standard header and footer are added outside the margins of each page.
Available in OS X v10.4 and later.
Solution:
Add a new bool field - addHeaderAndFooter.
NSPrintJobSavingFileNameExtensionHidden
A boolean NSNumber indicating whether the job’s file name extension should be hidden when the
jobDisposition
is
NSPrintSaveJob
. The default is NO.
Available in OS X v10.6 and later.
Solution:
Add a new bool field fileNameExtensionHidden
NSPrintSelectionOnly
An NSNumber object containing a Boolean value—if YES only the current selection is printed.
Available in OS X v10.6 and later.
Solution:
Store this in print options flags
via nsIPrintSettings::kEnableSelectionRB. We'll need to add options
to the common group.
NSPrintJobSavingURL
Available in OS X v10.6 and later.
NSPrintTime
An NSDate object that specifies the time at which printing should begin.
Available in OS X v10.4 and later.
TODO:
What is up with printSettings is null error when attempting to print?