Closed Bug 1602410 Opened 4 years ago Closed 4 years ago

Make `window.print()` work with tab-modal printing

Categories

(Core :: Printing: Setup, task, P1)

task

Tracking

()

RESOLVED FIXED
81 Branch
Fission Milestone M6c
Tracking Status
firefox73 --- disabled
firefox74 --- disabled
firefox81 --- fixed

People

(Reporter: jwatt, Assigned: emilio)

References

(Blocks 1 open bug)

Details

(Whiteboard: [print2020_v81])

Attachments

(1 file, 4 obsolete files)

(Edited 2020-08-10 to provide a useful summary and up-to-date understanding of what we need.)

We need window.print() to synchronously create the printing static clone document so that pages that do the following have the print only changes in the print output:

makeChangesThatShouldOnlyShowInThePrintOutput();
window.print();
undoChangesThatShouldOnlyShowInThePrintOutput();

However, for the new printing UI we need the static clone to be generated in the browser element contained within the print preview doorhanger that the frontend opens. Obviously at the time that window.print() is called in the content process, the doorhanger isn't open in the parent process though.

To achieve both the above we will need to either:

  • create and store the static clone synchronously during the window.print() call, message the parent to start printing, and the pick up and use the stored static clone after the roundprint to the parent to get it to open the doorhanger
  • send an IPDL message to the parent process to open the doorhanger UI in window.print(), and either spin an event loop until the parent sends back the browser to clone into, or else use a blocking IPDL message
Blocks: 1587459
Attachment #9114625 - Attachment description: Bug 1602410. Make `window.print()` invoke printing via the parent process using an IPDL actor. r=Gijs,bobowen → Bug 1602410. Make `window.print()` invoke printing via the parent process using a JSWindowActor. r=Gijs,kmag
Pushed by jwatt@jwatt.org:
https://hg.mozilla.org/integration/autoland/rev/bc3a104f8b20
Make `window.print()` invoke printing via the parent process using a JSWindowActor. r=Gijs,kmag

Meh. I've mistakenly used JS::NumberValue instead of JS::BooleanValue. Why do normal builds not complain about that?

Flags: needinfo?(jwatt)
Pushed by jwatt@jwatt.org:
https://hg.mozilla.org/integration/autoland/rev/edf3df2adebb
Make `window.print()` invoke printing via the parent process using a JSWindowActor. r=Gijs,kmag
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73

Backed out from Beta for suspicion of causing bug 1607671. This bug remains fixed on m-c for 74+.
https://hg.mozilla.org/releases/mozilla-beta/rev/93585cda453f

Regressions: 1607671
Regressions: 1608018
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: mozilla73 → ---

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:jwatt, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(jwatt)
Flags: needinfo?(jwatt)
Depends on: 1638162
Whiteboard: [print2020_v78]

Tracking for Fission Nightly (M6c)

Fission Milestone: --- → M6c
Whiteboard: [print2020_v78] → [print2020_v79]
Status: REOPENED → ASSIGNED
Whiteboard: [print2020_v79] → [print2020_v80]
Whiteboard: [print2020_v80] → [print2020_v81]
Depends on: 1652344
Attachment #9114625 - Attachment is obsolete: true
Assignee: jwatt → emilio
Priority: P2 → P1
Flags: needinfo?(emilio)
Blocks: 1658533

Stash it in the openWindowInfo, so that eventually the front-end creates
a hidden window.

This of course still needs some work. Things that I know need fixing:

  • Make the frontend not create a visible tab for window.print().
    Instead, probably just create a headless / hidden browser.

  • Make the print preview stuff work by either not creating a hidden
    browser for that case (creating the print preview UI in the
    window-opening codepath), or swapping frame loaders with the hidden
    window from the print preview UI.

  • Make the print preview viewer have an about:printpreview url (because
    it's special-cased in some cases).

  • Fix some other print-preview tests (I've fixed the main one).

  • Handle print preview settings changes. Right now I could just call
    printPreviewWindow.printPreview() again I guess, and that'd preserve
    behavior (and keep re-cloning clones), so may be worth doing to get
    this landed, but the idea is that eventually to update the print
    preview settings we don't go through window.printPreview() and
    instead go through a new API in the preview window, that just
    re-creates the print job and presentation.

Depends on D87062

Comment on attachment 9170014 [details]
Bug 1602410 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob.

As noted, some work still needed, but wdyt of something like this?

Attachment #9170014 - Flags: feedback?(nika)
Attachment #9170014 - Flags: feedback?(jwatt)

Comment on attachment 9170014 [details]
Bug 1602410 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob.

Added some comments on the revision - generally looks good

Attachment #9170014 - Flags: feedback?(nika) → feedback+

Do this by spinning the event loop until we've done the clone for
preview as appropriate.

This should be much less risky than finishing the previous patches
which would still be nice, but realistically landing them for 81 is not
going to happen.

This just returns without doing nothing in a couple cases, like when
there's already another modal dialog or such. That seems acceptable to
me, it's not clear what better way to do would be.

Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e650c0acb702
Make window.print() work with tab-modal printing. r=nika,geckoview-reviewers,agi
No longer depends on: 1638162
Summary: Make `window.print()` invoke printing via the parent process using an IPDL actor → Make `window.print()` work with tab-modal printing
Attachment #9168515 - Attachment is obsolete: true
Blocks: 1631440
No longer blocks: 1587459
Status: ASSIGNED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Flags: needinfo?(emilio)

Comment on attachment 9170014 [details]
Bug 1602410 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob.

Revision D87063 was moved to bug 1636728. Setting attachment 9170014 [details] to obsolete.

Attachment #9170014 - Attachment is obsolete: true
Attachment #9170014 - Flags: feedback?(jwatt)
Attachment #9170013 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: