Commit Graph

323 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
139ea8de9f Bug 1665779 - Null-check mPrt in nsPrintJob::InitPrintDocConstruction. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D91056
2020-09-22 21:28:15 +00:00
Emilio Cobos Álvarez
cb233b8098 Bug 1557645 - Clone OOP iframes in the right process. r=nika
This works, though probably we want to do some follow-up tweaks, like
the adding of the onload blocker and so on, so that we can avoid the
UpdateDimensions hack.

We may also want a PrintObject in the nsPrintJob tree, perhaps...

Differential Revision: https://phabricator.services.mozilla.com/D90310
2020-09-22 09:57:27 +00:00
Emilio Cobos Álvarez
6f7cd547ea Bug 1663826 - Keep freezing navigation during window.print() for compat. r=smaug
This broke in bug 1636728 because we started setting the bit in the
cloned docshell rather than the original one.

Behavior in other browsers seems to be a bit all over the place, but for
now keeping our behavior during window.print() seems sane.

Differential Revision: https://phabricator.services.mozilla.com/D90456
2020-09-16 22:55:19 +00:00
Emilio Cobos Álvarez
538cca122a Bug 968753 - Save per-printer settings on GTK. r=jwatt
I don't see any reason why this shouldn't work off-hand, there's no
gtk globals or such that fundamentally avoid sharing settings.

The PSPrinters stuff is gone so it's not needed to mess up with PS/CUPS
names.

The last used printer name stuff is now just a pref read, so there
shouldn't be sandbox violation shenanigans...

There are some restrictions on what can be set or what not (like, if you
set the paper name that may also override the paper size).

But these are problems that we have when restoring from prefs already,
so there's no reason we shouldn't do this, afaict.

Differential Revision: https://phabricator.services.mozilla.com/D90418
2020-09-16 15:31:45 +00:00
Emilio Cobos Álvarez
530438c493 Bug 1665125 - Make print background settings infallible. r=bobowen
This makes callers simpler.

Differential Revision: https://phabricator.services.mozilla.com/D90285
2020-09-16 11:21:41 +00:00
Narcis Beleuzu
5d85149494 Backed out changeset 0834b634ea07 (bug 1665125) for reftest failures. CLOSED TREE 2020-09-15 23:32:11 +03:00
Emilio Cobos Álvarez
7488a36a35 Bug 1665125 - Make print background settings infallible. r=bobowen
This makes callers simpler.

Differential Revision: https://phabricator.services.mozilla.com/D90285
2020-09-15 16:19:20 +00:00
Jonathan Watt
cbec31f4f6 Bug 1662222. Don't spin a nested event loop in nsPrintJob::DoCommonPrint when called by extensions. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D89681
2020-09-10 00:12:48 +00:00
Hiroyuki Ikezoe
4abda7368a Bug 1661873 - Generate nsRootPresShell for printing ducuments only if the document has no parent OR the parent is not going to be printed AND GetParentViewForRoot() is not null. r=smaug
Though there is no automated test for this change, I think the test cases in the
previous commit well cover the original issue (bug 468568) that downloadable
fonts are not rendered in printing.

Depends on D89095

Differential Revision: https://phabricator.services.mozilla.com/D89096
2020-09-03 01:39:11 +00:00
Nathan Froyd
55437f2e0c Bug 1662251 - stop assigning from NS_Convert* values, mostly; r=sg
This patch was generated by running:

```
perl -p -i \
     -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF8toUTF16\((.*)\);/\1CopyUTF8toUTF16(\3, \2);/;' \
     -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF16toUTF8\((.*)\);/\1CopyUTF16toUTF8(\3, \2);/;' \
     $FILE
```

against every .cpp and .h in mozilla-central, and then fixing up the
inevitable errors that happen as a result of matching C++ expressions with
regexes.  The errors fell into three categories:

1. Calling the convert functions with `std::string::c_str()`; these were
   changed to simply pass the string instead, relying on implicit conversion
   to `mozilla::Span`.
2. Calling the convert functions with raw pointers, which is not permitted
   with the copy functions; these were changed to invoke `MakeStringSpan` first.
3. Other miscellaneous errors resulting from over-eager regexes and/or the
   replacement not being type-aware.  These changes were reverted.

Differential Revision: https://phabricator.services.mozilla.com/D88903
2020-09-02 09:54:37 +00:00
Bob Owen
6ab1219056 Bug 1661975 part 2: Follow-up to fix nsPrintJob::FirePrintingErrorEvent. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D89160
2020-09-02 15:47:10 +00:00
Bob Owen
80124f1172 Bug 1661975: Add whether we have a selection to PrintPreviewResultInfo. r=jwatt
This is then used in the front end to set the option in the settings.

Differential Revision: https://phabricator.services.mozilla.com/D89045
2020-09-02 08:15:35 +00:00
Jonathan Watt
3eacf4eab0 Bug 1653319. Use the new FrameLoader.printPreview API in the frontend. r=mstriemer,emalysz,emilio
Differential Revision: https://phabricator.services.mozilla.com/D88704
2020-09-02 15:13:14 +00:00
Jonathan Watt
2e793fcf9a Bug 1653340. Add new FrameLoader.printPreview() API. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D88703
2020-09-01 11:00:36 +00:00
Emilio Cobos Álvarez
3f771f9cc1 Bug 1661137 - Decrement the document viewer's destroy blocker earlier. r=bobowen
Do it as soon as we're done printing, rather than waiting until the
print timer dies.

Differential Revision: https://phabricator.services.mozilla.com/D88569
2020-08-31 10:44:19 +00:00
Daniel Holbert
1682dcf563 Bug 1659005 part 4: Check for page-range-skipped pages for tab-modal print preview, and group them as unpainted additional children on the nearest PrintedSheetFrame. r=TYLin
For now, we *only* use this new page-skipping code during print preview, via a
PresContext::IsScreen() check.  There's a separate legacy codepath that we'll
continue to use for skipping pages during actual printing; see e.g.
nsPageSequenceFrame::DetermineWhetherToPrintPage().  I intend to replace that
codepath soon, but for now I'm leaving it intact, in the interests of making
this patch minimally invasive & low-risk for beta uplift.

Differential Revision: https://phabricator.services.mozilla.com/D87394
2020-08-29 00:58:14 +00:00
Razvan Maries
c4034afdea Backed out changeset ede12aa1b8b5 (bug 1661137) for perma failures on printcmd.py and browser_ext_tabs_saveAsPDF.js. CLOSED TREE 2020-08-28 16:31:40 +03:00
Emilio Cobos Álvarez
b3f086be0f Bug 1661137 - Decrement the document viewer's destroy blocker earlier. r=bobowen
Do it as soon as we're done printing, rather than waiting until the
print timer dies.

Differential Revision: https://phabricator.services.mozilla.com/D88569
2020-08-28 11:33:18 +00:00
Emilio Cobos Álvarez
0002390658 Bug 1661437 - Convert print.show_print_progress into an static pref. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D88400
2020-08-27 12:27:49 +00:00
Emilio Cobos Álvarez
4adaf5163a Bug 1661388 - Factor out the default print settings code. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D88397
2020-08-27 10:58:19 +00:00
Emilio Cobos Álvarez
2c0dea8fd4 Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.

For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).

 * In the modern UI case, this browser is swapped with the actual print
   preview clone, and the UI takes care of removing the browser.

 * In the print dialog / silent printing case, the printing code calls
   window.close() from nsDocumentViewer::OnDonePrinting().

 * We don't need to care about the old print preview UI for this case
   because it can't be open from window.print().

We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.

Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 17:45:12 +00:00
Daniel Holbert
2a2243433a Bug 1660502 part 1: Give nsIWebBrowserPrint a "rawNumPages" attribute. r=TYLin
This is backed by an existing nsPageSequenceFrame API, which this patch also
renames to use the word "Raw" for consistency across the full callstack.

Differential Revision: https://phabricator.services.mozilla.com/D87886
2020-08-24 23:53:11 +00:00
Bob Owen
22dab6dc02 Bug 1660463: Only allow printing of a selection when mDisallowSelectionPrint is false. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D88028
2020-08-24 14:29:29 +00:00
Hiroyuki Ikezoe
2eb939096e Bug 1660189 - Bail out from nsPrintJob::DoCommonPrint if the docshell was destroyed in beforeprint event handlers. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D87827
2020-08-21 04:58:49 +00:00
Jonathan Watt
9343bc2e26 Bug 1659489. Rename nsPrintJob's mIsDoingPrintPreview to mCreatedForPrintPreview. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D87296
2020-08-17 21:27:00 +00:00
Hiroyuki Ikezoe
3b9637ec3d Bug 1657911 - Call nsDeviceContext::UnregisterPageDoneCallback only in the parent process and only if IsSyncPagePrinting. r=jwatt
The call sites of nsDeviceContext::RegisterPageDoneCallback are in the parent
process along with the IsSyncPagePrinting check.

Differential Revision: https://phabricator.services.mozilla.com/D86868
2020-08-13 23:15:37 +00:00
Emilio Cobos Álvarez
a7cfa4a572 Bug 1658903 - Remove nsPrintJob::TurnScriptingOn. r=jwatt
This code was there to prevent stuff like bug 424377, but nowadays clone
documents are data documents to begin with, so they can't load scripts.

Differential Revision: https://phabricator.services.mozilla.com/D86948
2020-08-13 12:22:56 +00:00
Emilio Cobos Álvarez
39564e934a Bug 1658894 - Move selection range caching to Document::CreateStaticClone(). r=jwatt
This is needed to eventually make the print process able to process the
same static document twice.

Differential Revision: https://phabricator.services.mozilla.com/D86937
2020-08-13 11:11:35 +00:00
Bob Owen
5e8ad7b378 Bug 1655674: Prevent nsPrintJob::FinishPrintPreview running twice by checking mIsCreatingPrintPreview. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D86320
2020-08-07 09:32:45 +00:00
Bob Owen
89418687c5 Bug 1653334 part 2: Cache the selection ranges on subdocuments as we build the nsPrintObject tree. r=jwatt
This also refactors the selection printing code, so that as we build the tree we
record which nsPrintObject should be used if printing a Selection is chosen.

Differential Revision: https://phabricator.services.mozilla.com/D85600
2020-08-03 14:23:56 +00:00
Bob Owen
130e64ff00 Bug 1653334 part 1: Remove unused isRangeSelection and isIFrameSelected. r=jwatt
These unused members are removed from nsIWebBrowserPrint and PPrintingTypes
along with their supporting functions.

Differential Revision: https://phabricator.services.mozilla.com/D85007
2020-08-03 14:23:27 +00:00
Butkovits Atila
87642692f3 Backed out 2 changesets (bug 1653334) for reftest failures at test-print-selection.html. CLOSED TREE
Backed out changeset 6cc6bbaa91f0 (bug 1653334)
Backed out changeset 75a5873f02a4 (bug 1653334)
2020-08-03 15:35:37 +03:00
Bob Owen
702dc7a41a Bug 1653334 part 2: Cache the selection ranges on subdocuments as we build the nsPrintObject tree. r=jwatt
This also refactors the selection printing code, so that as we build the tree we
record which nsPrintObject should be used if printing a Selection is chosen.

Differential Revision: https://phabricator.services.mozilla.com/D85600
2020-08-03 08:54:12 +00:00
Bob Owen
cd8f4e508b Bug 1653334 part 1: Remove unused isRangeSelection and isIFrameSelected. r=jwatt
These unused members are removed from nsIWebBrowserPrint and PPrintingTypes
along with their supporting functions.

Differential Revision: https://phabricator.services.mozilla.com/D85007
2020-08-03 08:53:44 +00:00
Jonathan Watt
2fb0c36b37 Bug 1652967. Fix crash in nsPrintJob::DoPrint. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D85570
2020-07-31 12:19:44 +00:00
Emilio Cobos Álvarez
dd5edacaa9 Bug 1655474 - Don't crash when trying to resume print while the page is closing. r=jwatt
This is a pre-existing issue that could already happen before the
regressing bug but seems worth addressing anyways.

If we're destroying we're definitely not going to be able to print, so
return an error rather than crashing in funny ways otherwise.

Depends on D85038

Differential Revision: https://phabricator.services.mozilla.com/D85039
2020-07-28 22:00:45 +00:00
Emilio Cobos Álvarez
e8ca26e8d8 Bug 1655179 - Don't attach a progress listener until we've started to set up the print presentation. r=smaug
This is afaict a pre-existing (conceptual) issue before my patch, but
it was only theoretical because @font-face loads are triggered from
styling / layout, so we wouldn't trigger them until we initialize the
document.

The print setup may be asynchronous
(via nsPrintJob::Observe -> InitPrintDocConstruction -> ReflowDocList).

If we get the load event sooner than that, then we'd try to start
printing before we've ever called ReflowDocList which is what sets
everything up.

Thus we'd assert in debug builds here:

  https://searchfox.org/mozilla-central/rev/828f2319c0195d7f561ed35533aef6fe183e68e3/layout/printing/nsPrintJob.cpp#1453-1457

And crash in ReconstructAndReflow in release builds.

We don't care about what goes on before we start setting up the
presentation of the document, so defer setting up the
web-progress-listener until we do that.

Differential Revision: https://phabricator.services.mozilla.com/D84905
2020-07-26 22:16:32 +00:00
Emilio Cobos Álvarez
9b189f3136 Bug 1655106 - Minor cleanups to nsPrintJob. r=jwatt
* Remove silly checks for (bool && !bool) which are obviously
   redundant.
 * Use MOZ_TRY where appropriate.

Differential Revision: https://phabricator.services.mozilla.com/D84850
2020-07-24 18:16:16 +00:00
Erik Nordin
b6f4c52c9d Bug 1654406 - Fix Incorrect Ellipsis Offset When Printing Selections r=bobowen
- Fix double-counted ellipsis offset.
- Rename unselected to nonselected for consistency.

Differential Revision: https://phabricator.services.mozilla.com/D84448
2020-07-23 20:17:03 +00:00
Emilio Cobos Álvarez
3b7bbe1b28 Bug 1648064 - Make print preview documents wait properly for the document to be loaded. r=smaug
Otherwise my test fails intermittently on CI. We need to block on all
the load blockers because stuff like responsive images doesn't fire the
load directly but they do that as a micro task (blocking the load
event).

Differential Revision: https://phabricator.services.mozilla.com/D81989
2020-07-22 20:29:16 +00:00
Narcis Beleuzu
61c35a714a Backed out 6 changesets (bug 1648064) for wp failures on test_printpreview.xhtml . CLOSED TREE
Backed out changeset 8ac892c60eda (bug 1648064)
Backed out changeset 189401f7b6e8 (bug 1648064)
Backed out changeset 2598e2706bd0 (bug 1648064)
Backed out changeset 4ec12eb9788c (bug 1648064)
Backed out changeset f735d4f6b21f (bug 1648064)
Backed out changeset 0fed6928b53d (bug 1648064)
2020-07-22 21:28:10 +03:00
Emilio Cobos Álvarez
d32201b8f0 Bug 1648064 - Make print preview documents wait properly for the document to be loaded. r=smaug
Otherwise my test fails intermittently on CI. We need to block on all
the load blockers because stuff like responsive images doesn't fire the
load directly but they do that as a micro task (blocking the load
event).

Differential Revision: https://phabricator.services.mozilla.com/D81989
2020-07-22 14:39:47 +00:00
Emilio Cobos Álvarez
da7d72f1b0 Bug 1648064 - Remove some includes from nsPrintJob.h. r=jwatt
I had needed this before to export that header, and it's no longer
needed, but it seems useful anyways.

Depends on D81989

Differential Revision: https://phabricator.services.mozilla.com/D84252
2020-07-22 14:16:14 +00:00
Emilio Cobos Álvarez
f9a539a6ab Bug 1651947 - Scale the page sequence in print preview so that pages don't overflow the viewport horizontally. r=dholbert
This is going to be useful for the new print preview UI, which is in a
doorhanger and thus much more likely to be less than the page size.

We (ab)use the existing print preview scaling mechanism. We only need it
after reflowing all pages, so this works.

This whole scaling mechanism is all-in-all not amazing, but the patch is
less gross than I initially thought. It's nice, actually.

We could put the new behavior behind a pref trivially, if that's wanted,
but I honestly thing this behavior is better even without the doorhanger
ui.

Differential Revision: https://phabricator.services.mozilla.com/D83309
2020-07-15 11:16:43 +00:00
Jonathan Watt
ea23bf77cd Bug 1652344 p3. Stop creating an nsIPrintSettings in nsGlobalWindowOuter::PrintOuter. r=bobowen
The fallback code in nsPrintJob::DoCommonPrint to create an nsIPrintSettings if
none is passed in is never used, since all callers pass a settings object.
However, to simplify future changes I'd like nsGlobalWindowOuter::PrintOuter to
stop creating and passing in its own default valued nsIPrintSettings object.

This patch makes the fallback code that DoCommonPrint calls do what
nsGlobalWindowOuter::PrintOuter does, and makes the latter stop passing in a
settings object.

This patch also removes nsIWebBrowserPrint.globalPrintSettings since
nsGlobalWindowOuter::PrintOuter was its only consumer.

Differential Revision: https://phabricator.services.mozilla.com/D83268
2020-07-13 00:22:28 +00:00
Mihai Alexandru Michis
605e60e31b Backed out 2 changesets (bug 1652344) for causing failures in test_printpreview.xhtml
CLOSED TREE

Backed out changeset d2b66d810ab5 (bug 1652344)
Backed out changeset 075903436ef2 (bug 1652344)
2020-07-13 01:21:28 +03:00
Jonathan Watt
fccd18873d Bug 1652344 p2. Stop creating an nsIPrintSettings in nsGlobalWindowOuter::PrintOuter. r=bobowen
The fallback code in nsPrintJob::DoCommonPrint to create an nsIPrintSettings if
none is passed in is never used, since all callers pass a settings object.
However, to simplify future changes I'd like nsGlobalWindowOuter::PrintOuter to
stop creating and passing in its own default valued nsIPrintSettings object.

This patch makes the fallback code that DoCommonPrint calls do what
nsGlobalWindowOuter::PrintOuter does, and makes the latter stop passing in a
settings object.

This patch also removes nsIWebBrowserPrint.globalPrintSettings since
nsGlobalWindowOuter::PrintOuter was its only consumer.

Differential Revision: https://phabricator.services.mozilla.com/D83268
2020-07-12 19:33:49 +00:00
Jonathan Watt
edd1971ba9 Bug 1652342. Move the print settings handling code in nsPrintJob::DoCommonPrint to after the static cloning. r=bobowen
In preparation for spliting DoCommonPrint.

Differential Revision: https://phabricator.services.mozilla.com/D83266
2020-07-12 19:29:30 +00:00
Jonathan Watt
ff82c41998 Bug 1652322. Stop nsPrintJob::DoCommonPrint using its arguments after it creates the static clone. r=bobowen
I'm going to be splitting DoCommonPrint so that the parts that run after the
static clone is created happen after a roundtrip to the parent process.

Differential Revision: https://phabricator.services.mozilla.com/D83262
2020-07-12 16:36:27 +00:00
Jonathan Watt
0658eba870 Bug 1652318. Freeze docshell tree navigation at the same time for both print and print preview. r=bobowen
I specifically want to move this to happen before the static clone is made, in
preparation for splitting out the static clone logic from DoCommonPrint.

Differential Revision: https://phabricator.services.mozilla.com/D83260
2020-07-12 16:34:03 +00:00