Commit graph

98 commits

Author SHA1 Message Date
Daniel Holbert
834d608a51 Bug 1776289 part 2: Merge nsPrintJob::Initialize into the constructor. r=emilio
This patch doesn't change behavior; it's just collapsing logic from
nsPrintJob's Initialize method (which is now de-facto infallible) into the
constructor.

I'm also removing the "Methods needed by the DocViewer" header-comment since
it's clearly innacurate at this point. It's only surrounding this constructor
and GetSeqFrameAndCountSheets, which is silly since nsDocumentViewer uses more
of our API than that.

(I also placed TODO(dholbert) comments for a few things that looked odd, to
follow up on later. In particular, I noticed that nsDocumentViewer holds a
dedicated stack-owned RefPtr reference to nsPrintJob after creating it, which
superficially looks unnecessary. I don't want to risk changing behvior or
introducing a crash by removing that reference in this refactoring patch, so
I'm leaving that as-is and simply flagging it as suspicious.)

Depends on D150194

Differential Revision: https://phabricator.services.mozilla.com/D150195
2022-06-23 22:57:01 +00:00
Daniel Holbert
221e594b00 Bug 1776289 part 1: Change nsPrintJob::Initialize to take references instead of pointers, to avoid the need for unnecessary null-checks. r=emilio
This patch doesn't change behavior.

Depends on D150177

Differential Revision: https://phabricator.services.mozilla.com/D150194
2022-06-23 22:57:00 +00:00
Daniel Holbert
4685a0aa28 Bug 1776074 part 4: Use references instead of pointers for nsPrintObject::Init's Document and nsDocShell args (and in callers). r=emilio
This patch doesn't change behavior. It just changes to c++ reference types and
code-comments to indicate where we know that pointers have been null-checked
(and removes some null-checks that now become trivially-unnecessary).

I've added code-comments to justify why we know these args are non-null.
Generally, `nsPrintObject::Init`'s args are null-checked by the caller, except
in one case (in `nsPrintJob::DoCommonPrint`) where the Document* pointer in
question was _not_ directly null-checked by the caller. But fortunately, it is
null-checked earlier, higher up in the call-stack.  So, this patch simply
propagates the C++ reference type-conversion up to that point for additional
clarity.

Differential Revision: https://phabricator.services.mozilla.com/D150078
2022-06-23 22:56:59 +00:00
Jonathan Watt
4d4c2e7754 Bug 1770539 p9 - Move nsPrintData::mPrintObject to nsPrintJob. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146980
2022-05-22 09:37:58 +00:00
Jonathan Watt
617a76892b Bug 1770539 p7 - Move nsPrintData::mSelectionRoot to nsPrintJob. r=emilio
Depends on D146978

Differential Revision: https://phabricator.services.mozilla.com/D146979
2022-05-22 09:37:57 +00:00
Jonathan Watt
8827bc2beb Bug 1770539 p6 - Move nsPrintData::mPrintDocList to nsPrintJob. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146978
2022-05-22 09:37:57 +00:00
Jonathan Watt
224cfeb1b9 Bug 1770539 p5 - Move nsPrintData::mPreparingForPrint to nsPrintJob. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146977
2022-05-22 09:37:57 +00:00
Jonathan Watt
47516e9e83 Bug 1770539 p4 - Move nsPrintData::mNumPrintablePages to nsPrintJob. r=emilio
Depends on D146975

Differential Revision: https://phabricator.services.mozilla.com/D146976
2022-05-22 09:37:56 +00:00
Jonathan Watt
db89857906 Bug 1770539 p3 - Move nsPrintData::mShrinkRatio to nsPrintJob::mShrinkToFitFactor. r=emilio
Depends on D146974

Differential Revision: https://phabricator.services.mozilla.com/D146975
2022-05-22 09:37:56 +00:00
Jonathan Watt
c0b9f77a02 Bug 1770539 p2 - Move nsPrintData::mShrinkToFit to nsPrintJob. r=emilio
Depends on D146973

Differential Revision: https://phabricator.services.mozilla.com/D146974
2022-05-22 09:37:56 +00:00
Jonathan Watt
90a01d7930 Bug 1770539 p1 - Move nsPrintData::mPrintSettings to nsPrintJob. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146973
2022-05-22 09:37:55 +00:00
Jonathan Watt
981db60f5f Bug 1769999 - Remove the last of the nsPrintJob::mPrtPreview code. r=emilio
Since bug 1659432 landed, we no longer keep the nsPrintJob around across print
settings changes, only replacing the nsPrintData. Now that we throw away
everything on a settings change it doesn't make sense to have code that was
written for juggling nsPrintData objects. That code was just making things
difficult to understand.

Differential Revision: https://phabricator.services.mozilla.com/D146718
2022-05-19 09:38:19 +00:00
Jonathan Watt
45fd50ca0f Bug 1769993 - Bring some sanity to nsPrintJob's scaling/shrink-to-fit logic. r=emilio
The comments and structure of this code no longer made much sense after the
last 20 years of churn, including those made in bug 1659432 and bug 1552785.

Differential Revision: https://phabricator.services.mozilla.com/D146717
2022-05-19 07:08:16 +00:00
Iulian Moraru
7bc6abbc6e Backed out changeset 9273652dbd01 (bug 1769993) for causing mochitest-chrome failures on test_printpreview.xhtml. CLOSED TREE 2022-05-18 20:42:02 +03:00
Jonathan Watt
b60432d3eb Bug 1769993 - Bring some sanity to nsPrintJob's scaling/shrink-to-fit logic. r=emilio
The comments and structure of this code no longer made much sense after the
last 20 years of churn, including those made in bug 1659432 and bug 1552785.

Differential Revision: https://phabricator.services.mozilla.com/D146717
2022-05-18 16:45:59 +00:00
Jonathan Watt
1790ea2686 Bug 1769756 - Remove nsIWebBrowserPrint.currentPrintSettings. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D146569
2022-05-17 15:04:24 +00:00
Jonathan Watt
dfbf5426b6 Bug 1769717 - Remove nsPrintJob::GetPrintPreviewPresShell(). r=emilio
Long ago we used to play switcheroo with PresShells in order to print a
document, but for over a decade we've been cloning the document that is
to be printed (bug 487667). Since then we've had no need for this method.

Differential Revision: https://phabricator.services.mozilla.com/D146545
2022-05-17 11:36:20 +00:00
Jonathan Watt
7ea23646b7 Bug 1769508 - Remove the special case code for frameset shrink-to-fit. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146417
2022-05-16 12:27:49 +00:00
Jonathan Watt
41b151c8c4 Bug 1432651 p1 - Pass RemotePrintJobChild through to the places where it's needed. r=emilio
Given how nsIPrintSettings is passed around, stored and copied all over the
place, it's very hard to reason about where and when a RemotePrintJobChild is
needed or valid. This patch avoids all that by explicitly passing a
RemotePrintJobChild when it's needed.

Another reason to make this change is because RemotePrintJobChild really does
not belong on nsIPrintSettings. That interface is supposed to represent a
collection of settings for laying out the document that is to be printed.

Differential Revision: https://phabricator.services.mozilla.com/D146380
2022-05-16 08:38:01 +00:00
Jonathan Watt
ebabc1e31f Bug 1768919 - Avoid checking the original document for focus in nsPrintJob. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146110
2022-05-12 12:06:57 +00:00
Jonathan Watt
11eb91ba57 Bug 1768741 - Remove nsPrintJob::HasEverPrinted. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146016
2022-05-11 18:08:45 +00:00
Iulian Moraru
f8ed722831 Backed out changeset cb6bcb4d91d4 (bug 1768741) for causing build bustages on nsPrintJob.cpp. CLOSED TREE 2022-05-11 19:49:47 +03:00
Jonathan Watt
836361a17e Bug 1768741 - Remove nsPrintJob::HasEverPrinted. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D146016
2022-05-11 16:02:40 +00:00
Jonathan Watt
ac90ddff59 Bug 1745452 - Remove the print progress dialog code. r=mstriemer,bobowen,webdriver-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D133500
2021-12-16 15:12:33 +00:00
Butkovits Atila
7d46682c0e Backed out changeset 51d7c5d96ceb (bug 1745452) for causing failures at browser_all_files_referenced.js. CLOSED TREE 2021-12-16 15:13:34 +02:00
Jonathan Watt
f2d22001b0 Bug 1745452 - Remove the print progress dialog code. r=mstriemer,bobowen,webdriver-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D133500
2021-12-16 11:45:59 +00:00
Emilio Cobos Álvarez
a49800a500 Bug 1679706 - Communicate to the front-end whether there are no visible pages at all. r=jfkthame
This will allow them to react however they want to empty page ranges as
a result of another setting change.

Differential Revision: https://phabricator.services.mozilla.com/D98183
2020-12-02 21:48:03 +00:00
Emilio Cobos Álvarez
075593c873 Bug 1679706 - Cleanup a bit the page-sequence-using methods in nsPrintJob. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D98182
2020-12-02 17:17:17 +00:00
Emilio Cobos Álvarez
a68a0e6e0e Bug 1672864 - Don't resume printing too early. r=jfkthame
When we do the initial reflow, we remove nodes from the document if
we're printing the selection. If these operations cause one iframe to be
removed, for example, then we may get hit with an nsIWebProgress
notification synchronously, which may cause us to go through
MaybeResumePrintAfterResourcesLoaded too early (and thus twice), which
messes up our state.

The ideal solution would be to add us as a listener a bit later, but we
can't because we need to know whether we did load anything during the
initial reflow.

So instead of that, just avoid resuming print while we're doing the
reflow. We'll call MaybeResumePrintAfterResourcesLoaded a few lines
below.

Differential Revision: https://phabricator.services.mozilla.com/D94586
2020-10-23 18:34:05 +00:00
Daniel Holbert
3e52de68f4 Bug 1669774 part 2: Rename some APIs and variables for accuracy (s/page/sheet/) in nsPrintJob, nsPagePrintTimer, and nsDocumentViewer. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D92791
2020-10-07 21:00:26 +00:00
Emilio Cobos Álvarez
72936d9e85 Bug 1667400 - Remove PrintPreviewUserEventSuppressor. r=jwatt
Doesn't work at all with e10s / fission.

Differential Revision: https://phabricator.services.mozilla.com/D91440
2020-09-25 14:58:17 +00:00
Jonathan Watt
ad76c1dcba 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
4953377ea0 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
Emilio Cobos Álvarez
044b3c4332 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
e3a6a51032 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
Jonathan Watt
970f8373d2 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
Emilio Cobos Álvarez
68dd457e8b 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
Hiroyuki Ikezoe
103cf5ff04 Bug 1657515 - Constify some nsIDocumentViewerPrint methods. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D86149
2020-08-06 22:54:16 +00:00
Bob Owen
ada89eea81 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
c4f92dc077 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
076d3aa7ed 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
ac5872bd35 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
d5715ceb42 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
Sylvestre Ledru
843f943758 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D85678
2020-08-02 15:29:15 +00:00
Emilio Cobos Álvarez
a1687ac170 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
46367e2f7d 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
636792f039 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
f87a5320b9 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
Simon Giesecke
96fb649d21 Bug 1652017 - Remove unnecessary includes for expensive nsIFrame.h. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D83111
2020-07-15 13:44:39 +00:00
Emilio Cobos Álvarez
b769a57503 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