Closed Bug 1146454 Opened 11 years ago Closed 10 years ago

Remove CPOW usage in printing

Categories

(Toolkit :: Printing, defect)

defect
Not set
normal
Points:
2

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
e10s m8+ ---
firefox42 --- fixed

People

(Reporter: mossop, Assigned: mconley)

References

Details

Attachments

(2 files)

Using contentWindowAsCPOW in printing is sort of clunky and I think there is a straightforward way to remove it. Ideally we should only need the browser we print in and preview in to have message managers and nothing else so we can eventually drop contentWindowAsCPOW entirely.
Flags: qe-verify-
Flags: firefox-backlog+
Summary: Remote CPOW usage in printing → Remove CPOW usage in printing
Attached patch WIPSplinter Review
Having some difficulty getting printing to work at all on my machine but this sort of thing seems like a good idea. What do you think to switching to outer window IDs?
Attachment #8582002 - Flags: feedback?(mconley)
Status: NEW → ASSIGNED
Iteration: --- → 39.2 - 23 Mar
Comment on attachment 8582002 [details] [diff] [review] WIP This is a good idea. We might want to mark the pattern of passing the nsIDOMWindow directly as deprecated, and file a bug to remove it entirely down the line.
Attachment #8582002 - Flags: feedback?(mconley) → feedback+
Iteration: 39.2 - 23 Mar → 39.3 - 30 Mar
Iteration: 39.3 - 30 Mar → 40.1 - 13 Apr
Depends on: 1150120
See Also: → 1142013
Not high priority so I won't get to this soon.
Assignee: dtownsend → nobody
Iteration: 40.1 - 13 Apr → ---
tracking-e10s: --- → ?
Status: ASSIGNED → NEW
Blocks: 1141732
This blocks / solves one of my M8's, so marking this M8 and taking.
Assignee: nobody → mconley
Bug 1146454 - Stop using CPOWs for printing. r?felipe We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
https://reviewboard.mozilla.org/r/12617/#review11081 ::: toolkit/components/printing/content/printUtils.js:106 (Diff revision 1) > - * @param aBrowser (optional for non-remote browsers) > + * @param aBrowser (optional if aWindow is a non-remote nsIDOMWindow) Nit - aWindow -> aWindowOrWindowID ::: toolkit/components/printing/content/printUtils.js:108 (Diff revision 1) > * not necessary if aWindow came from a non-remote browser, but is Nit - aWindow -> aWindowOrWindowID ::: toolkit/components/printing/content/printUtils.js:111 (Diff revision 1) > - * browser must have its type attribute set to "content", > + * 1) aWindowOrWindowID comes from a remote browser and aBrowser is > + * not provided. Not true, and should probably just be removed. We should always pass the browser if we're passing the outer window ID, full stop. ::: toolkit/components/printing/content/printUtils.js:156 (Diff revision 1) > - if (!aBrowser) { > + if (!aBrowser) { > - throw new Error("PrintUtils.print could not resolve content window " + > + throw new Error("PrintUtils.print could not resolve content window " + > - "to a browser."); > + "to a browser."); Move this outside again.
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm Bug 1146454 - Stop using CPOWs for printing. r?felipe We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
Attachment #8629498 - Flags: review?(wmccloskey)
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm Bug 1146454 - Stop using CPOWs for printing. r?felipe We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
https://reviewboard.mozilla.org/r/12615/#review11295 Hey billm - normally, I'd get Mossop or felipe to review something like this, but both are on PTO. Are you comfortable doing it?
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm https://reviewboard.mozilla.org/r/12617/#review11305 This looks good, but I'd like a few changes. ::: toolkit/content/browser-content.js:396 (Diff revision 2) > - this.enterPrintPreview(objects.contentWindow); > + this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID)); It seems we don't support print preview for frames, so maybe we shouldn't bother sending the windowID and should just use |content| here. ::: toolkit/components/printing/content/printUtils.js:118 (Diff revision 2) > - print: function (aWindow, aBrowser) > + print: function (aWindowOrWindowID, aBrowser) There aren't very many callers of this function in Firefox, although there are a bunch of add-on callers. Let's do this: - Make a separate printWindow function that requires a <browser> and a window ID as arguments. We'll use this function throughout Firefox. - Provide a print method for add-on compat. It ignores all its arguments. It tries to find a gBrowser symbol on the global and prints gBrowser.selectedBrowser. (I know this is toolkit code, but it's only for backwards compat.) Please comment that this function exists only for add-on compatibility. If you do this, then you can drop the PrintWindow message entirely.
https://reviewboard.mozilla.org/r/12617/#review11305 > It seems we don't support print preview for frames, so maybe we shouldn't bother sending the windowID and should just use |content| here. When we send this message down from PrintUtils, we're sending the message through the message manager of the "print preview" browser - that's the browser in which we will be showing the print preview, and not the browser which is holding the content that we want to print preview. So we have to pass the outer window ID down, I'm afraid. > There aren't very many callers of this function in Firefox, although there are a bunch of add-on callers. Let's do this: > > - Make a separate printWindow function that requires a <browser> and a window ID as arguments. We'll use this function throughout Firefox. > - Provide a print method for add-on compat. It ignores all its arguments. It tries to find a gBrowser symbol on the global and prints gBrowser.selectedBrowser. (I know this is toolkit code, but it's only for backwards compat.) Please comment that this function exists only for add-on compatibility. > > If you do this, then you can drop the PrintWindow message entirely. Not just add-ons, I'm afraid - Thunderbird still uses this, so I'm going to cut them a break and support the original API for this method for now, but mark it deprecated.
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm Bug 1146454 - Stop using CPOWs for printing. r?billm We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
Attachment #8629498 - Attachment description: MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?felipe → MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm
https://reviewboard.mozilla.org/r/12615/#review11337 I've made the suggested changes, but I still need to run this through some tests. Will re-request review tomorrow, thanks!
(In reply to Mike Conley (:mconley) - Needinfo me! from comment #11) > Not just add-ons, I'm afraid - Thunderbird still uses this, so I'm going to > cut them a break and support the original API for this method for now, but > mark it deprecated. I just searched through comm-central and they only use the no-argument PrintUtils.print version. So I think my proposal would not break Thunderbird.
(In reply to Bill McCloskey (:billm) from comment #14) > (In reply to Mike Conley (:mconley) - Needinfo me! from comment #11) > > Not just add-ons, I'm afraid - Thunderbird still uses this, so I'm going to > > cut them a break and support the original API for this method for now, but > > mark it deprecated. > > I just searched through comm-central and they only use the no-argument > PrintUtils.print version. So I think my proposal would not break Thunderbird. Ok, fair enough - though I won't use gBrowser.selectedBrowser, since other apps probably don't have those defined. I'll use window.content for now.
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm Bug 1146454 - Stop using CPOWs for printing. r?billm We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
Attachment #8629498 - Flags: review?(wmccloskey)
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm Bug 1146454 - Stop using CPOWs for printing. r?billm We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
Attachment #8629498 - Flags: review?(wmccloskey)
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm Bug 1146454 - Stop using CPOWs for printing. r?billm We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
Attachment #8629498 - Flags: review?(wmccloskey)
Attachment #8629498 - Flags: review?(wmccloskey) → review+
Comment on attachment 8629498 [details] MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm https://reviewboard.mozilla.org/r/12617/#review11541 Looks great! Thanks for making the changes. ::: toolkit/components/viewsource/content/viewPartialSource.xul:42 (Diff revision 5) > - <command id="cmd_print" oncommand="PrintUtils.print();"/> > + <command id="cmd_print" oncommand="PrintUtils.printWindow(gBrowser.outerWindowID, gBrowser);"/> Does tabbrowser.xml define an outerWindowID property? ::: toolkit/components/viewsource/content/viewSource.xul:42 (Diff revision 5) > - <command id="cmd_print" oncommand="PrintUtils.print(gBrowser.contentWindowAsCPOW, gBrowser);"/> > + <command id="cmd_print" oncommand="PrintUtils.printWindow(gBrowser.outerWindowID, gBrowser);"/> Same.
(In reply to Bill McCloskey (:billm) from comment #20) > Comment on attachment 8629498 [details] > MozReview Request: Bug 1146454 - Stop using CPOWs for printing. r?billm > > https://reviewboard.mozilla.org/r/12617/#review11541 > > Looks great! Thanks for making the changes. > > ::: toolkit/components/viewsource/content/viewPartialSource.xul:42 > (Diff revision 5) > > - <command id="cmd_print" oncommand="PrintUtils.print();"/> > > + <command id="cmd_print" oncommand="PrintUtils.printWindow(gBrowser.outerWindowID, gBrowser);"/> > > Does tabbrowser.xml define an outerWindowID property? > > ::: toolkit/components/viewsource/content/viewSource.xul:42 > (Diff revision 5) > > - <command id="cmd_print" oncommand="PrintUtils.print(gBrowser.contentWindowAsCPOW, gBrowser);"/> > > + <command id="cmd_print" oncommand="PrintUtils.printWindow(gBrowser.outerWindowID, gBrowser);"/> > > Same. It does not! But it probably should. Thanks - good catch!
https://reviewboard.mozilla.org/r/12617/#review11541 > Does tabbrowser.xml define an outerWindowID property? Ah, I see what happened here. In the context of the viewSource.xul and viewPartialSource.xul documents, gBrowser refers to the <xul:browser> showing the source, not a <xul:tabbrowser>. Kinda confusing to use gBrowser between different windows to mean different things, but, well, there we have it.
(In reply to Mike Conley (:mconley) - Needinfo me! from comment #22) > Ah, I see what happened here. In the context of the viewSource.xul and > viewPartialSource.xul documents, gBrowser refers to the <xul:browser> > showing the source, not a <xul:tabbrowser>. Ah, I see. Disregard my comment then.
url: https://hg.mozilla.org/integration/fx-team/rev/dfd2a128d19ce8f485543428e09328f450d96791 changeset: dfd2a128d19ce8f485543428e09328f450d96791 user: Mike Conley <mconley@mozilla.com> date: Fri Jul 03 16:06:04 2015 -0400 description: Bug 1146454 - Stop using CPOWs for printing. r=billm We were passing around content window CPOWs before to indicate which content to send to the printer. This was, naturally, causing unsafe CPOW usage warnings - especially when attempting to get at the content window of an iframe with the context menu printing command. This patch changes the printing mechanism to use outer window IDs instead of CPOWs.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Blocks: 1190344
Blocks: 1195863
Depends on: 1265126
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: