Commit graph

89 commits

Author SHA1 Message Date
Ting-Yu Lin
b518ef30fa Bug 1888535 Part 5 - Remove DISPLAY_REFLOW. r=layout-reviewers,emilio
It is used in `Reflow()` implementations.

Differential Revision: https://phabricator.services.mozilla.com/D206317
2024-04-02 19:03:05 +00:00
Jonathan Watt
b0c778ba81 Bug 1833244 p2. Implement sheet orientation switching/rotation for page-orientation. r=AlaskanEmily,dholbert
Where supported (print preview and print-to-PDF), this implements changing the
orientation and/or rotation of print sheets, as appropriate, in response to CSS
`page-orientation`. When supported we:

- in the single page-per-sheet case, rotate the sheet in order to implement
  any `page-orientation` rotation on the sheet. Rotating the sheet is necessary
  so that when we output PDF files the pages visually have the correct
  orientation.

- in the multiple pages-per-sheet case, we already rotate individual pages in
  their grid cell. This commit keeps such pages rotated, as appropriate, but
  augments that behavior by switching the orientation of the sheet (based on
  the first page on the sheet), if necessary, to make best use of the space on
  the sheet. (We can't know what orientation any subsequent pages on the sheet
  will have, so we assume the same orientation as the first one.)

Depends on D179423

Differential Revision: https://phabricator.services.mozilla.com/D179448
2023-08-22 10:57:55 +00:00
Iulian Moraru
6e2fb6cde8 Backed out changeset 6db2de19f043 (bug 1833244) for causing wp failures on page-size-006-print.html. CLOSED TREE 2023-08-22 05:05:53 +03:00
Jonathan Watt
da5396b21d Bug 1833244 p2. Implement sheet orientation switching/rotation for page-orientation. r=AlaskanEmily,dholbert
Where supported (print preview and print-to-PDF), this implements changing the
orientation and/or rotation of print sheets, as appropriate, in response to CSS
`page-orientation`. When supported we:

- in the single page-per-sheet case, rotate the sheet in order to implement
  any `page-orientation` rotation on the sheet. Rotating the sheet is necessary
  so that when we output PDF files the pages visually have the correct
  orientation.

- in the multiple pages-per-sheet case, we already rotate individual pages in
  their grid cell. This commit keeps such pages rotated, as appropriate, but
  augments that behavior by switching the orientation of the sheet (based on
  the first page on the sheet), if necessary, to make best use of the space on
  the sheet. (We can't know what orientation any subsequent pages on the sheet
  will have, so we assume the same orientation as the first one.)

Depends on D179423

Differential Revision: https://phabricator.services.mozilla.com/D179448
2023-08-21 21:55:17 +00:00
Cristian Tuns
68a7302612 Backed out changeset bc3dcd234d91 (bug 1833244) for causing multiple failures with *page_size* CLOSED TREE 2023-08-21 11:15:08 -04:00
Jonathan Watt
a4b6e0c738 Bug 1833244 p2. Implement sheet orientation switching/rotation for page-orientation. r=AlaskanEmily,dholbert
Where supported (print preview and print-to-PDF), this implements changing the
orientation and/or rotation of print sheets, as appropriate, in response to CSS
`page-orientation`. When supported we:

- in the single page-per-sheet case, rotate the sheet in order to implement
  any `page-orientation` rotation on the sheet. Rotating the sheet is necessary
  so that when we output PDF files the pages visually have the correct
  orientation.

- in the multiple pages-per-sheet case, we already rotate individual pages in
  their grid cell. This commit keeps such pages rotated, as appropriate, but
  augments that behavior by switching the orientation of the sheet (based on
  the first page on the sheet), if necessary, to make best use of the space on
  the sheet. (We can't know what orientation any subsequent pages on the sheet
  will have, so we assume the same orientation as the first one.)

Depends on D179423

Differential Revision: https://phabricator.services.mozilla.com/D179448
2023-08-21 14:21:49 +00:00
Jonathan Watt
07bafd2423 Bug 1833244 p1. Create infrastructure to pass page dimensions to PrintTarget::BeginPage. r=dholbert,geckoview-reviewers,jonalmeida
OS print drivers/devices know nothing about page dimensions unless we tell
them. Previously, the physical page dimensions (including orientation) have
always been the same, so communicating their dimensions once at the start of
a print has been enough. In preparation for supporting different "physical"
page dimensions (in the immediate future only different page orientations) when
we save to PDF, we need to have the infrastructure to pass dimensions through
on a page-by-page basis. This patch adds that.

None of the PrintTarget subclasses do anything with this extra information yet,
but in a follow-up patch PrintTargetPDF will use this information to create
PDFs with mixed page orientations.

Differential Revision: https://phabricator.services.mozilla.com/D179423
2023-07-10 14:26:12 +00:00
Stanca Serban
c75ef6f238 Backed out 3 changesets (bug 1833244) for causing multiple failures.
Backed out changeset 7bc8c25b2935 (bug 1833244)
Backed out changeset 4576af83a4ec (bug 1833244)
Backed out changeset 90a5bbba7b9c (bug 1833244)
2023-06-03 18:36:21 +03:00
Jonathan Watt
c8fa25f263 Bug 1833244 p3. Implement sheet orientation switching/rotation for page-orientation. r=AlaskanEmily,dholbert
Where supported (print preview and print-to-PDF), this implements changing the
orientation and/or rotation of print sheets, as appropriate, in response to CSS
`page-orientation`. When supported we:

- in the single page-per-sheet case, rotate the sheet in order to implement
  any `page-orientation` rotation on the sheet. Rotating the sheet is necessary
  so that the pages in the PDF files that we output are correct.

- in the multiple pages-per-sheet case, we already rotate individual pages in
  their grid cell. This change keeps such pages rotated, as appropriate, but
  augments that behavior by switching the orientation of the sheet (based on
  the first page on the sheet) if necessary to best place the page to make
  maximum use of the space.

Depends on D179423

Differential Revision: https://phabricator.services.mozilla.com/D179448
2023-06-03 14:21:38 +00:00
Jonathan Watt
597c1a2778 Bug 1833244 p2. Create infrastructure to pass page dimensions to PrintTarget::BeginPage. r=dholbert
OS print drivers/devices know nothing about page dimensions unless we tell
them. Previously, the physical page dimensions (including orientation) have
always been the same, so communicating their dimensions once at the start of
a print has been enough. In preparation for supporting different "physical"
page dimensions (in the immediate future only different page orientations) when
we save to PDF, we need to have the infrastructure to pass dimensions through
on a page-by-page basis. This patch adds that.

None of the PrintTarget subclasses do anything with this extra information yet,
but in a follow-up patch PrintTargetPDF will use this information to create
PDFs with mixed page orientations.

Differential Revision: https://phabricator.services.mozilla.com/D179423
2023-06-03 14:21:37 +00:00
Iulian Moraru
3cfea4753c Backed out changeset 9fce1abd1c50 (bug 1833244) for causing build bustages on nsDeviceContextAndroid.h. CLOSED TREE 2023-05-31 16:31:53 +03:00
Jonathan Watt
d4e8510ca6 Bug 1833244 p1. Create infrastructure to pass page dimensions to PrintTarget::BeginPage. r=dholbert
OS print drivers/devices know nothing about page dimensions unless we tell
them. Previously, the physical page dimensions (including orientation) have
always been the same, so communicating their dimensions once at the start of
a print has been enough. In preparation for supporting different "physical"
page dimensions (in the immediate future only different page orientations) when
we save to PDF, we need to have the infrastructure to pass dimensions through
on a page-by-page basis. This patch adds that.

None of the PrintTarget subclasses do anything with this extra information yet,
but in a follow-up patch PrintTargetPDF will use this information to create
PDFs with mixed page orientations.

Depends on D179395

Differential Revision: https://phabricator.services.mozilla.com/D179423
2023-05-31 13:02:26 +00:00
Jonathan Watt
25f286fb47 Bug 1835713. Change the print code to not assume that sheets all have the same dimensions. r=dholbert
This code doesn't change behavior itself. The same sheet size is cached on all
sheets. Patches for future bugs will change that.

Differential Revision: https://phabricator.services.mozilla.com/D179395
2023-05-30 12:09:04 +00:00
Norisz Fay
e70ec39aa9 Backed out changeset b448658be51d (bug 1835713) for causing build bustages on PrintedSheetFrame.cpp CLOSED TREE 2023-05-30 13:58:26 +03:00
Jonathan Watt
2bba312341 Bug 1835713. Change the print code to not assume that sheets all have the same dimensions. r=dholbert
This code doesn't change behavior itself. The same sheet size is cached on all
sheets. Patches for future bugs will change that.

Differential Revision: https://phabricator.services.mozilla.com/D179395
2023-05-30 10:40:58 +00:00
Jonathan Watt
84688dc421 Bug 1824852. Ensure PrintedSheetFrame calls MoveOverflowToChildList before reflow. r=dholbert
The intention is to allow PrintedSheetFrame::Reflow to access the page style
prior to reflowing its child so that it can decide whether to apply page style
to the sheet (in the case of one page-per-sheet). This will happen in a
subsequent bug.

Differential Revision: https://phabricator.services.mozilla.com/D173773
2023-03-30 11:29:29 +00:00
Jonathan Kew
1b3e69f8aa Bug 1815404 - Remove refcounting from gfxContext. r=gfx-reviewers,lsalzman
Depends on D170367

Differential Revision: https://phabricator.services.mozilla.com/D170369
2023-02-21 07:28:24 +00:00
Emilio Cobos Álvarez
49f269b507 Bug 1812868 - Tweak scrollbar scaling set-up. r=mstange
This is to make GetDPIRatioForScrollbarPart thread-safe for stylo usage.

This was using the widget for bug 1727289, but just looking at the print
preview scale is enough to fix that.

Reviewed in: https://phabricator.services.mozilla.com/D168148
2023-02-20 00:01:12 +01:00
Sandor Molnar
2bc700c04b Backed out 2 changesets (bug 1812868) for causing bug 1817539. CLOSED TREE
Backed out changeset 07c689de250c (bug 1812868)
Backed out changeset e7d370501c50 (bug 1812868)
2023-02-18 09:34:04 +02:00
Emilio Cobos Álvarez
ad4bd6a3ba Bug 1812868 - Expose scrollbar-inline-size as a CSS variable to chrome code. r=mstange
For that we need to:

 * Make GetDPIRatioForScrollbarPart thread-safe: This was using the
   widget for bug 1727289, but just looking at the print preview scale
   is enough to fix that.

 * Make nsPresContext::UseOverlayScrollbars() thread-safe: We store the
   RDM pane stuff in the pres context.

The rest is pretty straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D168148
2023-02-17 21:15:06 +00:00
Ting-Yu Lin
f101e2077d Bug 1464761 Part 4 - Remove nsReflowStatus::mTruncated bit. r=dholbert
In the description of the mTruncated bit, its purpose is the same as calling
SetInlineLineBreakBeforeAndReset(). We've removed all its usages in previous
patches, so the bit is no longer needed.

Differential Revision: https://phabricator.services.mozilla.com/D151461
2022-07-27 21:55:18 +00:00
Miko Mynttinen
ddec6eef59 Bug 1714584 - Part 1: Decouple nsDisplayList internal list from nsDisplayItems r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D138152
2022-02-22 23:42:18 +00:00
Norisz Fay
2121660ce9 Backed out 2 changesets (bug 1714584) per devs request for causing crashes a=backout
Backed out changeset 3baead3e079b (bug 1714584)
Backed out changeset a2da895a58ce (bug 1714584)
2022-02-22 16:41:57 +02:00
Miko Mynttinen
28474c7ad2 Bug 1714584 - Part 1: Decouple nsDisplayList internal list from nsDisplayItems r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D138152
2022-02-22 00:44:25 +00:00
Daniel Holbert
080e18fa47 Bug 1663722: Make nsPageSequenceFrame gracefully handle SizeToContent calls. r=emilio
nsPageSequenceFrame does a thing where it grows its desired size to fit the
AvailableISize and ComputedBSize (under the assumption that those are the
actual dimensions of our scrollport, which it wants to make maximal use of).

This behavior causes trouble when it's reflowed under the privileged
'sizeToContent' JS API.  That API makes us reflow with nscoord_MAX as the
viewport's ComputedBSize(), and this nscoord_MAX value gets passed down to be
the nsPageSequenceFrame's ComputedBSize as well.  When we reach the code in
question, we dutifully grow the desired size to that bogus huge value, which is
clearly wrong.

This patch addresses this issue by simply declining to grow the desired size in
the scenario where ComputedBSize() is unconstrained.  This leaves us with
reasonable values for our desired size (which are actually based on the
content, which makes it the right thing to do for the purpose of a
SizeToContent() call).

Differential Revision: https://phabricator.services.mozilla.com/D135762
2022-01-13 06:08:51 +00:00
Greg Tatum
d642b72ac3 Bug 1715892 - Unify locale/DateTimeFormat to mozilla::intl::AppDateTimeFormat; r=platform-i18n-reviewers,dminor
I considered removing this class initially, but it's actually a pretty
useful abstraction over the DateTimeFormat interface when used
specifically with Gecko. It applies the OS preferences and provides some
caching behavior.

Differential Revision: https://phabricator.services.mozilla.com/D131671
2021-12-01 17:41:37 +00:00
Marian-Vasile Laza
3bfa529b3e Backed out 6 changesets (bug 1715892, bug 1719735) for causing bc test failures. CLOSED TREE
Backed out changeset 196952bd8c9c (bug 1715892)
Backed out changeset 9105fe01c025 (bug 1715892)
Backed out changeset 4c15d1a24ccd (bug 1715892)
Backed out changeset 2c328b84285f (bug 1715892)
Backed out changeset 8fcdcdf44b62 (bug 1719735)
Backed out changeset c48f398e301f (bug 1719735)
2021-11-30 23:30:59 +02:00
Greg Tatum
9b5497020e Bug 1715892 - Unify locale/DateTimeFormat to mozilla::intl::AppDateTimeFormat; r=platform-i18n-reviewers,dminor
I considered removing this class initially, but it's actually a pretty
useful abstraction over the DateTimeFormat interface when used
specifically with Gecko. It applies the OS preferences and provides some
caching behavior.

Differential Revision: https://phabricator.services.mozilla.com/D131671
2021-11-30 19:05:58 +00:00
Emilio Cobos Álvarez
a4e7c9e510 Bug 1722945 - Support break-inside: avoid-{page,column}. r=TYLin
break-before/after: page|column seem harder because you need to deal
with nested breaks, I think, but this should be straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D121206
2021-08-03 17:56:58 +00:00
Noemi Erli
89a565ea85 Backed out changeset 67c33ba5566e (bug 1722945) for causing bustage in nsContainerFrame.cpp 2021-08-03 20:35:10 +03:00
Emilio Cobos Álvarez
3d1b4f252f Bug 1722945 - Support break-inside: avoid-{page,column}. r=TYLin
break-before/after: page|column seem harder because you need to deal
with nested breaks, I think, but this should be straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D121206
2021-08-03 13:59:47 +00:00
Jonathan Kew
63f05b6d5a Bug 454059 - Add a new PaintForPrinting display list builder mode, and only create a Linkifier when printing. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D114474
2021-05-11 17:00:30 +00:00
Emilio Cobos Álvarez
3aa2544989 Bug 1700379 - Move code dealing with transform getters to the frame that we actually wrap its contents around. r=miko
This shouldn't change behavior, but simplifies the setup quite a bit, I
think.

Differential Revision: https://phabricator.services.mozilla.com/D109510
2021-05-04 18:46:44 +00:00
Alexandru Michis
6641f79c95 Backed out changeset 0229f8dc291a (bug 1700379) for causing failures in test_printpreview.xhtml
CLOSED TREE
2021-05-03 22:10:12 +03:00
Emilio Cobos Álvarez
baca44f241 Bug 1700379 - Move code dealing with transform getters to the frame that we actually wrap its contents around. r=miko
This shouldn't change behavior, but simplifies the setup quite a bit, I
think.

Differential Revision: https://phabricator.services.mozilla.com/D109510
2021-05-03 17:59:47 +00:00
Emilio Cobos Álvarez
51a69dce6a Bug 1700379 - Remove unused nsDisplayListBuilder::IsInPageSequence. r=miko
Differential Revision: https://phabricator.services.mozilla.com/D109509
2021-03-23 18:02:49 +00:00
Mats Palmgren
6adb31f151 Bug 1698235 - Add some error handling when using RemotePrintJobChild which may be destroyed. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D108711
2021-03-18 19:39:09 +00:00
Emilio Cobos Álvarez
5a6d8228c8 Bug 1691858 - Minor cleanup of our @page rule setup. r=AlaskanEmily
Actually, there's not so much we can improve right now, in the sense
that:

 * We need the ::-moz-page-content pseudo-element to be able to set
 `display` on the page, since that's a style rule rather than a @page
 rule. We could get away without it.

 * Keeping the current code-path (slightly cleaned up) is less code, for
 now at least. We can have a separate code-path or what not that
 actually performs the @page rule selector-matching and what not if
 needed when we get to named pages or other page selectors. Selectors
 like :first should be pretty trivial to implement, actually.

We make some paged mode anon boxes non-inheriting anon boxes. This
allows us to share the styles and is generally nicer. They don't need to
inherit from anywhere.

We could remove the origin handling and don't look at UA rules or what
not, but it seems pretty harmless to do that.

We also fix the name of the pseudo-elements to match the capitalization.

Differential Revision: https://phabricator.services.mozilla.com/D104772
2021-02-12 15:42:38 +00:00
Daniel Holbert
741687aeee Bug 1686494 part 2: When gathering printed canvas elements for PDF.js, skip canvases on pages that aren't in the user's custom print range. r=TYLin
This code currently does a recursive tree-traversal to get a list of all canvas
elements that might be used for PDF.js content, so that we can invoke the
appropriate callbacks on them to let PDF.js prepare for printing.

In this patch, I'm adjusting the outermost level of that traversal to make it
aware of the fact that PrintedSheetFrames may now contain many skipped
nsPageFrames whose content we don't want to render.

Depends on D101941

Differential Revision: https://phabricator.services.mozilla.com/D101942
2021-01-15 19:39:09 +00:00
Daniel Holbert
1ad8b7a2ee Bug 1686494 part 1: Change return type of nsPageSequence::GetCurrentSheetFrame to the actual concrete type, PrintedSheetFrame*, instead of nsIFrame*. r=TYLin
This patch doesn't change behavior; it just adds a static_cast to a
more-specific type that we know the variable has, and updates the signature and
callsites.

(The next patch will make use of the fact that we know this type.)

Differential Revision: https://phabricator.services.mozilla.com/D101941
2021-01-15 18:17:47 +00:00
Daniel Holbert
af327bde4e Bug 1669905 part 3: Add support for 2 and 6 as options for pages-per-sheet, in the print-related frame classes (and add tests for these values). r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D99553
2021-01-05 02:13:03 +00:00
Daniel Holbert
345e76ee7a Bug 1681623: Simplify pages-per-sheet data & logic to only store a single track count (either the row or column count), since the other one is implicit. r=TYLin
This patch doesn't change behavior.  It's just a simplification of the data
that we track for our different pages-per-sheet mode (with some minor
refactoring of the logic involved).

This is a necessary step towards implementing support for 2 and 6
pages-per-sheet (which are referenced in comments included in this patch,
and which will be implemented separately in bug 1669905)

Differential Revision: https://phabricator.services.mozilla.com/D99180
2020-12-10 00:58:43 +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
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
Dan Minor
c7c8e3f274 Bug 1669573 - Rename kTimeFormatSeconds and kTimeFormatNoSeconds; r=zbraniecki
This renames kTimeFormatSeconds to kTimeFormatLong and kTimeFormatNoSeconds to
kTimeFormatShort. This is consistent with the naming used for date format
selectors.

Differential Revision: https://phabricator.services.mozilla.com/D93011
2020-10-15 12:20:15 +00:00
Daniel Holbert
86836a67bf Bug 1631452 part 2: Add the pages-per-sheet info to nsSharedPageData and use it to control the number of pages that end up on a PrintedSheetFrame. r=TYLin,mattwoodrow
The idea here is that we reflow each page as if it were the only page on its
sheet, and then we transform it as-needed to put it in the right
"pages-per-sheet" cell, at paint time.

LIMITATION: Right now I haven't implemented the values "2" and "6", since those
will involve a bit of extra complexity to rotate the sheet to be orthogonal to
the page sizes (and to only do that if the page's aspect ratio merits it). That
will be covered in followup bug 1669905.

Differential Revision: https://phabricator.services.mozilla.com/D86800
2020-10-13 23:30:42 +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
63230729cd Bug 1669375 part 2: Remove code that partially implemented the "print only even/odd pages" feature. r=jwatt
This code looked like it might work, but it seems to have only ever been backed
by per-printer about:config prefs.  I believe we only ever exposed UI for this
feature on Linux, via the native GTK dialog; and even there, the UI doesn't
actually seem to have done anything -- it was never wired up to the actual
implementation of even/odd page-skipping.

Differential Revision: https://phabricator.services.mozilla.com/D92528
2020-10-06 15:33:29 +00:00
Emilio Cobos Álvarez
c921f4ff34 Bug 1664227 - The default page margin should be at least the unwriteable section, but not added on top. r=jwatt
We were adding the unwriteable to the default margin. I was going to
consider not painting the headers / footers if they overlapped with the
content box of the page, but turns out our default configuration
overlaps slightly at the bottom, so I just punted on that.

Users can remove the headers / footers quite easily anyhow.

Differential Revision: https://phabricator.services.mozilla.com/D89794
2020-09-10 18:03:04 +00:00