Commit Graph

259 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
9db2aa0440 Bug 1699837 - Make sure that remote iframes honor print settings. r=mattwoodrow
This fixes it since we honor the print resolution properly now.

Differential Revision: https://phabricator.services.mozilla.com/D115263
2021-06-13 09:16:53 +00:00
Dorel Luca
71abb3ab93 Backed out changeset 43a82597dade (bug 1699837) for Crashtest in layout/printing/crashtests/1671503.html. CLOSED TREE 2021-06-11 19:48:10 +03:00
Emilio Cobos Álvarez
7af763acbe Bug 1699837 - Make sure that remote iframes honor print settings. r=mattwoodrow
This fixes it since we honor the print resolution properly now.

Differential Revision: https://phabricator.services.mozilla.com/D115263
2021-06-11 13:07:55 +00:00
Emilio Cobos Álvarez
d455c7de64 Bug 1712130 - Make print.print_via_parent a static pref. r=layout-reviewers,jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D115612
2021-05-20 17:05:33 +00:00
Emma Malysz
d2b69538dd Bug 1675965, do not store file name in preference value for save to pdf printers r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D113413
2021-04-29 17:42:54 +00:00
Emilio Cobos Álvarez
8c1efa7251 Bug 1707977 - Null-check print data in nsPrintJob::DoPrint. r=layout-reviewers,dholbert
It's unclear how this can happen (the caller also null-checks, but then
again it also reconstructs a bunch of stuff, so...).

Differential Revision: https://phabricator.services.mozilla.com/D113815
2021-04-29 17:03:00 +00:00
Simon Giesecke
a598a0c7c5 Bug 1679522 - Use <> style for including windows system headers. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D98895
2021-03-25 10:19:44 +00:00
Simon Giesecke
ad01a10a3b Bug 1634281 - Use nsTHashMap instead of nsDataHashtable. r=xpcom-reviewers,necko-reviewers,jgilbert,nika,valentin
Note that this patch only transforms the use of the nsDataHashtable type alias
to a directly equivalent use of nsTHashMap. It does not change the specification
of the hash key type to make use of the key class deduction that nsTHashMap
allows for in some cases. That can be done in a separate step, but requires more
attention.

Differential Revision: https://phabricator.services.mozilla.com/D106008
2021-03-10 10:47:47 +00:00
Simon Giesecke
0b443059fd Bug 1693306 - Simplify some uses of LookupOrInsertWith by GetOrInsertNew. r=xpcom-reviewers,necko-reviewers,dragana,nika
Differential Revision: https://phabricator.services.mozilla.com/D105479
2021-02-26 09:22:54 +00:00
Simon Giesecke
4f75368dcb Bug 1691913 - Rename nsBaseHashtable::GetOrInsert(With) to LookupOrInsert(With). r=xpcom-reviewers,necko-reviewers,jgilbert,dragana,nika
The functions should be called "Lookup" rather than "Get" because they return
a DataType& (rather than UserDataType).

Differential Revision: https://phabricator.services.mozilla.com/D105472
2021-02-26 09:11:45 +00:00
Simon Giesecke
d2caea36fa Bug 1691894 - Simplify uses of WithEntryHandle that only use OrInsert(With) by using GetOrInsertWith. r=xpcom-reviewers,necko-reviewers,jgilbert,nika
Differential Revision: https://phabricator.services.mozilla.com/D104676
2021-02-22 12:07:46 +00:00
Alexis Beingessner
07f2f659c6 Bug 1686616 - make StringBundle use Components instead of Services. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D105531
2021-02-18 13:26:32 +00:00
Simon Giesecke
40403773d0 Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in layout. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D104202
2021-02-09 18:19:39 +00:00
Daniel Holbert
2cedf5494d Bug 1669905 part 2: Add nsIPrintSettings APIs to handle the possibility that pages and sheets may have orthogonal orientation, in pages-per-sheet printouts. r=jfkthame
This patch does three things, all centered around these new APIs:

 (1) Add the APIs themselves -- some nsIPrintSettings methods to reason about
the sheet-orientation being potentially flipped to accomodate 2 and 6
pages-per-sheet.

 (2) Use these new APIs, where appropriate, in places where we previously used
the page-orientation to set up the platform-native print-settings objects and
print-target. Now, we'll use the *sheet* orientation instead of the page
orientation, to be sure we produce the appropriately-oriented platform-native
surfaces.  Also, for symmetry, this patch adds similar logic to the reverse
codepaths, where we update an existing nsIPrintSettings object based on a
platform-native print-settings object.

 (3) Update nsPrintJob's code that informs nsPresContext about the page-size.
This patch makes sure that this code uses the *page* size, rather than the
*sheet* size, in cases where they differ.  (The code that consumes this
nsPresContext::GetPageSize API, e.g. our CSS media-query code, really does want
the page size, not the sheet size.)

Differential Revision: https://phabricator.services.mozilla.com/D100372
2021-01-05 02:24:00 +00:00
Emilio Cobos Álvarez
9c5e37f7c2 Bug 1681095 - Add a privileged API to tell the print dialog whether a selection belongs to the previewed page vs. an iframe. r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D98991
2020-12-10 10:52:41 +00:00
Emilio Cobos Álvarez
6a45983303 Bug 1679706 - Fix an obvious typo in nsPrintJob::GetIsEmpty().
This will get tested when the front-end uses the value.

Differential Revision: https://phabricator.services.mozilla.com/D98575
2020-12-03 10:33:06 +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
771dd03229 Bug 1669854 - Add a single pageRanges print setting. r=nordzilla
... which is an array of pairs of ranges, and use it instead of the
existing printRange / startPage / endPage settings.

Differential Revision: https://phabricator.services.mozilla.com/D96093
2020-11-07 16:01:57 +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
Emilio Cobos Álvarez
21a0be097f Bug 1671503 - Handle documents from iframes that haven't changed remoteness yet correctly. r=nordzilla
See the comment. A bit racy, but some of the time crashtest crashes
without the patch.

Null-check is just paranoia.

Differential Revision: https://phabricator.services.mozilla.com/D93756
2020-10-16 20:46:00 +00:00
Dorel Luca
44946f3402 Backed out changeset 6d63e8bc04bf (bug 1671503) for Crashtest failures in layout/printing/crashtests/1671503.html. CLOSED TREE 2020-10-16 22:13:43 +03:00
Emilio Cobos Álvarez
9cad68877b Bug 1670876 - Add support for printing selection in shadow dom. r=nordzilla
Recursive the things all :^)

The fix to the "corresponding node" bits in Document.cpp should be
pretty straight-forward. The fix in nsPrintJob is a bit more subtle:

The way printing selection works is literally "select everything else,
then call Selection.deleteFromDocument on that". We need to do the same
with shadow DOM, which involves skipping over shadow trees, and dealing
with selecting bits in ancestor trees as needed.

Note that for multi-range-selection case this technically relies on the
order of the ranges being shadow-tree-inclusive. We don't support
multi-range selection in shadow dom well, afaict, but I've added a
comment to the code to that effect.

Differential Revision: https://phabricator.services.mozilla.com/D93357
2020-10-16 17:36:37 +00:00
Emilio Cobos Álvarez
09c912b47a Bug 1671503 - Handle documents from iframes that haven't changed remoteness yet correctly. r=nordzilla
See the comment. A bit racy, but some of the time crashtest crashes
without the patch.

Null-check is just paranoia.

Differential Revision: https://phabricator.services.mozilla.com/D93756
2020-10-16 17:37:00 +00:00
Emilio Cobos Álvarez
dc6e67221c Bug 1670816 - Handle remote subframe clones slightly earlier. r=nika
Otherwise we end up creating an in-process docshell and an initial,
non-static subdocument. This usually won't cause badness, but is wrong
and _can_ cause badness when printing selection etc.

The assertion I added is hit on existing tests and would've caught this.

Also fix another violation by grabbing the original docshell to clone
from before actually performing the clone, which could be null (and we'd
leave an initial document there). That would cause failures in
layout/printing/crashtests/1662259.html.

Differential Revision: https://phabricator.services.mozilla.com/D93279
2020-10-13 18:13:30 +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
Daniel Holbert
fd2a60b29e Bug 1669774 part 1: Rename some nsPageSequenceFrame APIs and vars with s/page/sheet/for accuracy. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D92789
2020-10-07 20:59:05 +00:00
Daniel Holbert
06a402acb0 Bug 1661868 part 2: Unify page-range handling logic, to assume all PrintedSheetFrames should be printed (and let them manage page-range-based skipping during layout). r=TYLin
This patch does the following things:

(1) It removes the legacy page-range-handling function
"DetermineWhetherToPrintPage()", and it now will always print every
PrintedSheetFrame.

(2) It activates PrintedSheetFrame's page-range handling function so that it
can take over responsibility for skipping pages during print operations.

(3) It adjusts the nsPrintJob code that kicks off individual asynchronous
"print the next page" operations (which is now really "print the next
PrintedSheetFrame).  This nsPrintJob code used to have page-range-related
handling interwoven into it, and that handling isn't necessary anymore now that
we're handling page-skipping up front at layout time.

(4) It replaces the mPageNum member-var (which tracks which page we're about to
print or are currently printing) with mCurrentSheetIdx, which is now a 0-based
index into the list of PrintedSheetFrame instances.

(5) It removes nsPrintData:mNumPagesPrinted, which was only used for
progress-bar-completion updates & which basically tracked the same information
that I'm tracking in the new mCurrentSheetIdx variable.

There's some additional cleanup that we should do after this lands (e.g. some
s/page/sheet/ renamings) but I'm holding off on that for now, to keep this
patch relatively targeted.

Differential Revision: https://phabricator.services.mozilla.com/D92660
2020-10-07 20:51:56 +00:00
Daniel Holbert
675e1e5b28 Bug 1669409: Convert the nsIPrintSettings:kEnableSelectionRB flag into a boolean, since it's the only entry in a bitfield. r=jwatt,emilio
This was the last flag that the PrintOptions bitfield was tracking.

So, this patch is effectively converting that bitfield (and its alias
"PrintOptionsBits") into a new, simpler boolean field named
"isPrintSelectionRBEnabled".

Differential Revision: https://phabricator.services.mozilla.com/D92542
2020-10-07 00:36:51 +00:00
Jonathan Watt
7ea14b32ec Bug 1669390. Fix silent printing telemetry when print.tab_modal.enabled is true. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D92531
2020-10-06 10:02:49 +00:00
Emilio Cobos Álvarez
941e868780 Bug 1668767 - Make "print selection" setting independent of page range. r=jfkthame
It conceptually is, and this will allow to have UI independent of the
page range in bug 140718.

Differential Revision: https://phabricator.services.mozilla.com/D92201
2020-10-02 13:59:48 +00:00
Edgar Chen
3af8ce6d7a Bug 1667081 - Part 1: Replace usage of nsIFocusManager with nsFocusManager; r=hsivonen
This patch is bascially done by:
perl -p -i -e "s/nsIFocusManager\* /nsFocusManager* /g;" $( find . -name *.cpp )
perl -p -i -e "s/nsCOMPtr<nsIFocusManager>/RefPtr<nsFocusManager>/g;" $( find . -name *.cpp )

Differential Revision: https://phabricator.services.mozilla.com/D91287
2020-09-29 07:21:09 +00:00
Bogdan Tara
8f6c53bdf5 Backed out 9 changesets (bug 1667081) for assertion failure on nsFocusManager CLOSED TREE
Backed out changeset 156ab3eba505 (bug 1667081)
Backed out changeset 2e37f347082c (bug 1667081)
Backed out changeset 8f59cef879ae (bug 1667081)
Backed out changeset 1298ff140218 (bug 1667081)
Backed out changeset 91342c822425 (bug 1667081)
Backed out changeset aafb1878c590 (bug 1667081)
Backed out changeset 2252e975f0d7 (bug 1667081)
Backed out changeset c3bac5f407d2 (bug 1667081)
Backed out changeset b1e6e81396ae (bug 1667081)
2020-09-28 20:02:52 +03:00
Edgar Chen
6abd74544d Bug 1667081 - Part 1: Replace usage of nsIFocusManager with nsFocusManager; r=hsivonen
This patch is bascially done by:
perl -p -i -e "s/nsIFocusManager\* /nsFocusManager* /g;" $( find . -name *.cpp )
perl -p -i -e "s/nsCOMPtr<nsIFocusManager>/RefPtr<nsFocusManager>/g;" $( find . -name *.cpp )

Differential Revision: https://phabricator.services.mozilla.com/D91287
2020-09-28 14:04:12 +00:00
Jonathan Kew
2d346ebd7e Bug 1666110 - Add telemetry for paper size used when printing. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D91105
2020-09-25 22:19:40 +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
Emilio Cobos Álvarez
722ad5b0f7 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
a4e300194a 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
567d300760 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
e6b821e340 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
706ceffb4b 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
38f63aa9b6 Backed out changeset 0834b634ea07 (bug 1665125) for reftest failures. CLOSED TREE 2020-09-15 23:32:11 +03:00
Emilio Cobos Álvarez
f3927b672a 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
42f409de3c 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
c9ac4c645c 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
cfb8fb313f 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
0c55d42a71 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
5cb94890b3 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
937e0617f0 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
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