Closed
Bug 1278537
Opened 9 years ago
Closed 9 years ago
Print dimensions aren't passed when printing silently via the parent
Categories
(Core :: Printing: Output, defect)
Tracking
()
RESOLVED
FIXED
mozilla50
People
(Reporter: r.chrzanowski, Assigned: bobowen)
Details
(Whiteboard: sbwc1)
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 OPR/37.0.2178.54
Steps to reproduce:
1. Create preferences:
print.printer_PDFCreator.print_headercenter = "header"
print.printer_PDFCreator.print_paper_height = 400
print.printer_PDFCreator.print_paper_width = 400
print.printer_PDFCreator.print_paper_size_unit = 1
where PDFCreator is your default printer name
2. Print page in e10s window
3. Print page in non-e10s window
4. set preference print.always_print_silent = "true"
5. Print page in e10s window
6. Print page in non-e10s window
Actual results:
Pages printed in steps 2., 3., 6. have custom header and custom dimensions.
Page printed in step 5 has custom header and default dimensions.
Expected results:
All pages printes should have had custom header and custom dimensions.
Reporter | ||
Comment 1•9 years ago
|
||
I know it is similar to bug 1260413 and I have mentioned it in bug 1255336 but both cases are closed now.
Before Firefox 50 attempt to print silently ended with an error. Now it's only that seemingly I can't change print dimensions.
Component: Untriaged → Printing: Output
Product: Firefox → Core
![]() |
||
Comment 2•9 years ago
|
||
bob, any ideas here? appears to have something to do with print.always_print_silent.
Flags: needinfo?(bobowen.code)
tracking-e10s:
--- → ?
Assignee | ||
Comment 3•9 years ago
|
||
Thanks again for finding and reporting this.
Looks like this is only when printing via the parent, it works if I set that to false, which is what we have for non-Nightly.
So this blocks content process sandbox, but not e10s.
The settings in the parent must be getting out of sync somehow, I'll get onto it.
Assignee: nobody → bobowen.code
Status: UNCONFIRMED → ASSIGNED
tracking-e10s:
? → ---
Ever confirmed: true
OS: Unspecified → Windows
Hardware: Unspecified → All
Summary: Print dimensions aren't passed when printing silently in e10s → Print dimensions aren't passed when printing silently via the parent
Whiteboard: sbwc1
Assignee | ||
Comment 4•9 years ago
|
||
As I've said before the whole way this print settings initialisation happens is pretty convoluted, particularly on Windows.
I can't wait to address this, probably in bug 1236015, but this should fix this issue for now.
MozReview-Commit-ID: AgRaoIjee2t
Attachment #8761555 -
Flags: review?(jmathies)
![]() |
||
Updated•9 years ago
|
tracking-e10s:
--- → -
Flags: needinfo?(bobowen.code)
![]() |
||
Comment 5•9 years ago
|
||
Comment on attachment 8761555 [details] [diff] [review]
When print settings have been initialized from prefs use them when initializing from the printer
Review of attachment 8761555 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/windows/nsDeviceContextSpecWin.cpp
@@ +460,5 @@
>
> + // If the settings have already been initialized from prefs then pass these to
> + // GetDataFromPrinter, so that they are saved to the printer.
> + bool initializedFromPrefs;
> + nsresult rv =
I think you want to either set initializedFromPrefs initially to false or check rv before returning early.
Attachment #8761555 -
Flags: review?(jmathies) → review+
Assignee | ||
Comment 6•9 years ago
|
||
(In reply to Jim Mathies [:jimm] from comment #5)
> I think you want to either set initializedFromPrefs initially to false or
> check rv before returning early.
Oh yes, thanks, I'll add a check on rv before landing.
Pushed by bobowencode@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1f78f3a9a9ba
When print settings have been initialized from prefs use them when initializing from the printer. r=jimm
Comment 8•9 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox50:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Reporter | ||
Comment 9•9 years ago
|
||
I've just updated all my Firefoxes and I'm still unable to print silently with custom dimensions in Nightly. It works ok in FDE and in Nighlty without e10s.
Assignee | ||
Comment 10•9 years ago
|
||
(In reply to r.chrzanowski from comment #9)
> I've just updated all my Firefoxes and I'm still unable to print silently
> with custom dimensions in Nightly. It works ok in FDE and in Nighlty without
> e10s.
Damn, I'll take another look and see if I can still reproduce.
Just need to finish this other thing first so I'll leave an ni?
Flags: needinfo?(bobowen.code)
Assignee | ||
Comment 11•9 years ago
|
||
(In reply to r.chrzanowski from comment #9)
> I've just updated all my Firefoxes and I'm still unable to print silently
> with custom dimensions in Nightly. It works ok in FDE and in Nighlty without
> e10s.
I just re-tried the STR in the Description and it's working for me.
Are you using different steps?
Flags: needinfo?(bobowen.code) → needinfo?(r.chrzanowski)
Reporter | ||
Comment 12•9 years ago
|
||
Hi,
sorry for long time with no answer, had no time to look at that.
It seems you are right, I must have done that differently that time because it works now by the listed steps. The other way worked the same before and that's why I may have checked it like that.
We have an addon which calls printing in frame-script like that:
var printWindow = window; //window variable passed from webpage we want to print
var ifreq = printWindow.QueryInterface(Ci.nsIInterfaceRequestor);
var gwebBrowserPrint = ifreq.getInterface(Ci.nsIWebBrowserPrint);
gwebBrowserPrint.print(printSettings, null); // printSetting - an object with print settings
And when the preference print.always_print_silent = true print settings like printSettings.headerStrCenter are working well but printSettings.paperWidth and printSettings.paperHeight seem to be ignored.
Sorry for confusing you.
Assignee | ||
Comment 13•9 years ago
|
||
(In reply to r.chrzanowski from comment #12)
> Hi,
> sorry for long time with no answer, had no time to look at that.
> It seems you are right, I must have done that differently that time because
> it works now by the listed steps. The other way worked the same before and
> that's why I may have checked it like that.
>
> We have an addon which calls printing in frame-script like that:
>
> var printWindow = window; //window variable passed from webpage we want to
> print
> var ifreq = printWindow.QueryInterface(Ci.nsIInterfaceRequestor);
> var gwebBrowserPrint = ifreq.getInterface(Ci.nsIWebBrowserPrint);
> gwebBrowserPrint.print(printSettings, null); // printSetting - an object
> with print settings
>
> And when the preference print.always_print_silent = true print settings like
> printSettings.headerStrCenter are working well but printSettings.paperWidth
> and printSettings.paperHeight seem to be ignored.
>
> Sorry for confusing you.
OK, I could look into why that isn't working, but in bugs 1189846 and 1274937, I added a new function to nsFrameLoader to allow printing to be called from the parent process.
It would be better if you used this as there will be further changes to printing from the child, that will probably remove the ability to pass your own print settings there.
The new function is exposed through toolkit/content/widgets/browser.xml, so you call something like the following to trigger printing for the browser:
browser.print(browser.outerWindowID, printSettings, printProgressListener);
* browser.outerWindowID - can be replaced with the window ID for a frame to print that
* printSettings - is optional
* printProgressListener - is optional and is basically an nsIWebProgressListener that can be used to track the print, where:
** onStateChange gets start / stop messages
** onProgressChange receives progress updates per page
** onStatusChange is called if there is an error during printing
Reporter | ||
Comment 14•9 years ago
|
||
Finally I will have some time to look into that. I will use your tips, thank you for your help.
Reporter | ||
Comment 15•9 years ago
|
||
I have trouble reaching browser.print. I have no access to gBrowser global anywhere in my addon (main part which is initiated first or frame-scripts).
I've tried reaching it by using browser = getMostRecentBrowserWindow() but its print() function doesn't seem to print, return or throw anything so it's not the one I'm looking for I guess.
I've also tried using content.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.print()
(query interface just as in toolkit/content/widgets/browser.xml)
(or by QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIFrameLoaderOwner))
but only to end up with
"Component does not have requested interface" nsresult: "0x80004002 (NS_NOINTERFACE)" error.
I know I call it from framescript but I don't know how to QueryInterface in any other way.
I also know I'm not talking about a bug now but just wanted to ask if is it possible to reach that browser.print(browser.outerWindowID, printSettings, printProgressListener) in any other way than by reaching gBrowser (from xul overlay as I understand).
And sorry, I still have trouble understanding Firefox parent-child etc. mechanics...
Reporter | ||
Comment 16•9 years ago
|
||
Ok, I think I managed to get to that function, I'm ashamed it took me so long.
var browserWindow = windowUtils.getMostRecentBrowserWindow();
var printSettingsService = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(Ci.nsIPrintSettingsService);
var printSettings = printSettingsService.newPrintSettings;
printSettings.headerStrCenter="customheader!";
printSettings.paperSizeUnit = 1;
printSettings.paperWidth = parseFloat(350);
printSettings.paperHeight = parseFloat(350);
printSettings.printSilent = true;
browserWindow.gBrowser.getBrowserForOuterWindowID(event.objects.winID).print(event.objects.winID,printSettings,null);
event.objects.winID is outerWindowID value passed in a message from framescript.
The window seems to print ok, dimensions and header are custom.
printSettings.printSilent value does not matter.
However print.always_print_silent preference set to true makes custom page dimensions get ignored. Page prints only with a custom header.
Maybe once again I misunderstood and that print() function isn't the one you were talking about?
Reporter | ||
Comment 17•9 years ago
|
||
Ok, I think it's working right now. I don't know if it's because I kept making some mistake (no idea what mistake exactly) or that I updated Nightly two times yesterday has something to do with it. My mistake probably. All in all I'm able to print with custom dimensions with
browser.print(browser.outerWindowID, printSettings, printProgressListener);
Sorry for all that spam.
Assignee | ||
Comment 18•9 years ago
|
||
(In reply to r.chrzanowski from comment #17)
> Ok, I think it's working right now. I don't know if it's because I kept
> making some mistake (no idea what mistake exactly) or that I updated Nightly
> two times yesterday has something to do with it. My mistake probably. All in
> all I'm able to print with custom dimensions with
> browser.print(browser.outerWindowID, printSettings, printProgressListener);
> Sorry for all that spam.
Glad that you got it sorted out.
Thanks for your help with ironing out issues in the recent printing changes.
Flags: needinfo?(r.chrzanowski)
You need to log in
before you can comment on or make changes to this bug.
Description
•