You need to
before you can comment on or make changes to this bug.
The UI client has a callback to request printing a frame. The main problem is that printing happens in the WebProcess, but the GtkPrintOperation is created in the UI process. The GtkPrintOperation creates the cairo context we should render into (UI). A solution might be not using GtkPrintOperation and create the print dialog in the UI process with GtkPrintUnixDialog and GtkPrintJob directly.
Hrm. The issue with just passing a bitmap here is that we'd like to render onto a PDF surface, right?
Right, we can't use bitmaps, the surface created by GtkPrintOperation might be pdf or ps when using cups, ps when using papi and lpr, pdf, ps or svg when printing to a file and win32 printing surface in windows.
Another solution might be to run the print dialog in the web process like we currently do for auth dialogs. I don't like the idea but it might work.
Chromium uses GtkPrintUnixDialog + GtkPrintJob in unix FWIW.
For the record, I'm pro the creation of the dialog in the UI process with the settings then piped through the IPC to the web process for the actual printing, like Carlos proposed, and with the creation of the WebKitPrintOperation object.
Yes, the idea is to use GtkPrintDialogUnix in the UI process, without exposing it in the API, using WebKitPrintOperation, the same way GtkPrintOperation does. This way someone could add win32 support using the window native printing dialog, using the same API. This object will run the dialog and send the print settings and page setup to the web process thought IPC. In the web process a GtkPrintJob object will be created using the print settings. GtkPrintJob creates the cairo surface using gtk printing backends. Then the frame is rendered into the printing surface and the job sent to the printer. This is the general ideal for the basic functionality.
Making this a meta bug since I'm going to split the work into several patches:
- Initial printing support in WebProcess
- Initial API
- Manual capabilities (copies, collate, reverse, multiple pages per sheet, scale, etc.). Maybe using a different bug per capability.