Commit Graph
105 Commits
Author SHA1 Message Date
Sylvestre Ledru 55481ac4b5 Bug 2023419 - Remove Emacs/Vim modelines from layout/ r=emilio,firefox-style-system-reviewers,layout-reviewers
replaced by .editorconfig

Differential Revision: https://phabricator.services.mozilla.com/D287852
2026-03-17 12:05:43 +00:00
Emilio Cobos Álvarez ba0e228d4f Bug 2000639 - Remove nsViewManager. r=jwatt
After the previous patches, nsViewManager is basically a backpointer to
its pres shell.

Remove it and just make PresShell manage the root view directly. After
this is done, we can decide what to do about nsView (which is itself
little more than a widget listener that forwards to pres shell right
now).

This technically starts listening to mParentWidget slightly later (on
pres shell creation), but I think that's ok.

Differential Revision: https://phabricator.services.mozilla.com/D272890
2025-11-28 10:48:18 +00:00
Emilio Cobos Álvarez a8a2311474 Bug 1976457 - Sort includes in layout/. r=janv,dshin
Interesting bit is layout/.clang-format, the rest is all automated.

Differential Revision: https://phabricator.services.mozilla.com/D256616
2025-07-09 13:24:00 +00:00
Jonathan Watt efb5a74fbc Bug 1865480. Rename nsIContentViewer to nsIDocumentViewer. r=layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D193987
2023-11-21 12:45:59 +00:00
Daniel Holbert 2cb6d8f464 Bug 1776074 part 7: Remove mFrameType member (and PrintObjectType in general) from nsPrintObject.h. r=emilio
This patch does not change behavior (other than a minor correctness fix in some
off-by-default logging; see below).

As shown in the removed line of the init list, this mFrameType member-var's
semantics are equivalent to a null-check of the mParent member-var.  So: rather
than encoding that same information twice, this patch simplifies to just
directly null-check the mParent pointer at all the usage sites.

Before this patch, nsPrintJob.cpp had two different patterns for logging
mFrameType; sometimes with a global `gFrameTypesStr` array, and other times
with a local `types` array (with shorter 2-character strings).  I've converted
both of these to helper-functions.

In the case of the `types` array, the old code used a 4-value array, which was
interesting since the enum type only had 2 possible values. This discrepancy is
just due to an oversight in bug 1769508, where we recently condensed the enum
from 4 values to 2; that bug technically should've condensed these arrays as
well (but didn't do so).  This left these arrays' enum-to-string mapping being
wrong (since eIFrame changed its numeric value from 2 to 1 in bug 1769508), but
probably nobody has used this logging code in a while, so nobody
noticed. Anyway: in this patch, I'm restoring the mappings that we had before
that change (so we'll log "DC" for root print objects and "IF" for non-root
i.e. iframe-flavored print objects).

Differential Revision: https://phabricator.services.mozilla.com/D150177
2022-06-23 22:57:00 +00:00
Daniel Holbert 3dd2a8498d Bug 1776074 part 6: Simplify nsPrintObject init list. r=emilio
Move two assignments to the declaration site, and remove an unnecessary
nullptr assignment (for a nsCOMPtr which is nullptr by default).

Depends on D150079

Differential Revision: https://phabricator.services.mozilla.com/D150176
2022-06-23 22:57:00 +00:00
Daniel Holbert 8ec0a8475a Bug 1776074 part 5: Merge nsPrintObject's effectively-infallible Init function into constructor. r=emilio
This patch doesn't change behavior; it's just refactoring.

The pre-existing Init code is now clearly infallible, now that earlier patches
have removed all of Init's NS_ENSURE_STATE arg-null-checks (which were Init's
only failure-returning codepaths).

So: now that it's infallible, we can just merge the Init() code directly into
the constructor.

This lets us promote some member-variables to be 'const' as well, since they
will now be initialized in the init list and are never modified after that.

Differential Revision: https://phabricator.services.mozilla.com/D150079
2022-06-23 22:56:59 +00:00
Daniel Holbert 574940c643 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
Daniel Holbert 2578254c73 Bug 1776074 part 3: Merge nsPrintObject's Init methods into one method. r=emilio
This patch doesn't change behavior.

The two init functions were already pretty similar.  This patch merges them,
and uses the "aParent" arg as a signal for which variant we're handling (with
the "root" variant being signalled via a null value).

This usage of aParent (to distinguish between variants) is valid, as long as we
can assume that the old `InitAsNestedObject` variant was always guaranteed to
receive a non-null value for its aParent arg.  (That would mean that we're OK to
use that arg's nullness as a way to distinguish between the two variants in
their new merged form.)

And indeed, we're safe to make this assumption, since there's only one callsite
for the `InitAsNestedObject` version (which is in
`nsPrintJob::BuildNestedPrintObjects`), and it dereferences the pointer before
calling into this init function.  So, the pointer has to be non-null, or else
we would have crashed at the earlier dereference.

Therefore, this conversion (and usage of aParent to distinguish between
variants) is valid.

(Spoiler alert: a later patch in this series will merge this Init() method
into the constructor. I'm doing this as a multi-step process with this
intermediate state, in order to hopefully make it easier to reason about the
conversion and confirm that it's valid.)

Differential Revision: https://phabricator.services.mozilla.com/D150077
2022-06-23 22:56:59 +00:00
Daniel Holbert da05d2045c Bug 1776074 part 1: Remove unused 'aForPrintPreview' param from nsPrintObject::InitAsRootObject. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D150075
2022-06-23 22:56:58 +00:00
Jonathan Watt 34b623a4cf 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 14625b6760 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 4aff27e443 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 d65361fde9 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
Nika Layzell 1d362d87fa Bug 1729092 - Remove dead nsPrintObject::mDidCreateDocShell, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D124511
2021-09-07 14:22:42 +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
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
Tom Tung 6a1958c9d8 Bug 1654935 - Copy over COOP header from new document to the docshell in nsPrintObject; r=nika
The COOP header is set to BrowsingContext only in Document::StartDocumentLoad.
If the replaced document has a different COOP header from one in its docshell.
Then, we can crash while creating a window global child for a new inner window.

Differential Revision: https://phabricator.services.mozilla.com/D85127
2020-08-05 17:14:38 +00:00
Bogdan Tara cd2baf7993 Backed out changeset b5a3e838eaec (bug 1654935) for nsPrintObject.cpp related bustage CLOSED TREE 2020-08-04 22:21:45 +03:00
Tom Tung 3b5d75dd5f Bug 1654935 - Copy over COOP header from new document to the docshell in nsPrintObject; r=nika
The COOP header is set to BrowsingContext only in Document::StartDocumentLoad.
If the replaced document has a different COOP header from one in its docshell.
Then, we can crash while creating a window global child for a new inner window.

Differential Revision: https://phabricator.services.mozilla.com/D85127
2020-08-04 19:05:04 +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
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
Daniel Holbert 9f3edb1b87 Bug 1652788: Preemptively fix unified build bustage in layout/{base,generic,printing}. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D83534
2020-07-14 18:15:49 +00:00
Jonathan Watt 7e12213a34 Bug 1642236. Make all printing "print as is" printing. r=bobowen
nsPrintObject::InitAsNestedObject made sure that all nsPrintObjects were set to
print-as-is except for frameset documents and their sub-documents. (Note the
setting of mParent->mPrintAsIs, which would actually set the root nsPrintObject
to print-as-is if it wasn't a frameset document!).

The SetPrintAsIs() calls in nsPrintJob::EnablePOsForPrinting would then
subsequently also set those frameset and frame nsPrintObjects to be print-as-is
in all but one edge case, namely printing a selection when there isn't a focused
window (which I'm not sure is even be possible).

Differential Revision: https://phabricator.services.mozilla.com/D77621
2020-06-02 15:18:04 +00:00
Jonathan Watt cddd60977b Bug 1642162. Remove nsPrintJob.cpp's MapContentToWebShells and MapContentForPO functions. r=bobowen
We nowadays already directly set nsPrintObject->mContent in
nsPrintObject::InitAsNestedObject.  This patch adds the setting of mFrameType
and PrintAsIs that MapContentForPO does, making MapContentToWebShells and
MapContentForPO redundant.

Differential Revision: https://phabricator.services.mozilla.com/D77597
2020-06-02 21:03:20 +00:00
Jonathan Watt 7e3eacf1db Bug 1642233. Rename nsPrintObject's mDontPrint and IsPrintable for consistency with its EnablePrinting. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D77616
2020-05-31 19:00:42 +00:00
Emilio Cobos Álvarez b1fc84a629 Bug 1640605 - Remove IsInAnonymousSubtree / IsRootOfAnonymousSubtree. r=edgar
In favor of the NativeAnonymous versions which they forward to.

Done automatically with:

  rg -l 'IsInAnonymousSubtree' | xargs sed -i 's/IsInAnonymousSubtree/IsInNativeAnonymousSubtree/g'

And removing the function definitions afterwards.

Differential Revision: https://phabricator.services.mozilla.com/D76681
2020-05-25 11:43:51 +00:00
Hiroyuki Ikezoe 7e25625df5 Bug 1640108 - Move nsPrintJob::SetPrintPO into nsPrintObject class and rename it to EnablePrinting. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D76456
2020-05-22 09:57:12 +00:00
Hiroyuki Ikezoe e84e59ce66 Bug 1640108 - Move SetPrintAsIs in nsPrintObject. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D76455
2020-05-22 09:56:55 +00:00
Mirko Brodesser 83ce60cb3f Bug 1634663: part 4) Declare callers of Selection::GetRangeAt const in layout code. r=masayuki
Depends on D73446

Differential Revision: https://phabricator.services.mozilla.com/D73447
2020-05-02 23:46:01 +00:00
Nika Layzell 0ff86374e5 Bug 1580565 - Part 3: Simplify API for creating independent BCs, r=farre
There were previously a number of different APIs for creating BrowsingContext
instances. This simplifies them into two major cases: "CreateDetached", which
allows for creating BrowsingContexts which are related to other
BrowsingContexts, and "CreateIndependent" which creates new, fully unrelated,
browsing contexts.

Differential Revision: https://phabricator.services.mozilla.com/D71237
2020-04-24 18:33:01 +00:00
Narcis Beleuzu f160c77a9f Backed out 7 changesets (bug 1580565) for bustages on nsDocShell.cpp . CLOSED TREE
Backed out changeset 8237f9a307f8 (bug 1580565)
Backed out changeset 47f5698d6c72 (bug 1580565)
Backed out changeset e1802670dcc4 (bug 1580565)
Backed out changeset 0a44c410b59b (bug 1580565)
Backed out changeset 20dbcfc9eacc (bug 1580565)
Backed out changeset cdf2b600e779 (bug 1580565)
Backed out changeset a421d33d03ce (bug 1580565)
2020-04-24 05:31:55 +03:00
Nika Layzell e80a99caca Bug 1580565 - Part 3: Simplify API for creating independent BCs, r=farre
There were previously a number of different APIs for creating BrowsingContext
instances. This simplifies them into two major cases: "CreateDetached", which
allows for creating BrowsingContexts which are related to other
BrowsingContexts, and "CreateIndependent" which creates new, fully unrelated,
browsing contexts.

Differential Revision: https://phabricator.services.mozilla.com/D71237
2020-04-23 21:52:44 +00:00
Erik Nordin d2a3c7ef88 Bug 1620289 - Part 1 Clone Selection Ranges For Printing r=jwatt
- Clones selection ranges to the static document for printing
- Static docs can remove selections without referring to original doc

Differential Revision: https://phabricator.services.mozilla.com/D71110
2020-04-23 16:41:49 +00:00
Andreea Pavel 8cd16cba50 Backed out 7 changesets (bug 1580565) for bc failures on a CLOSED TREE
Backed out changeset e44e0a6366f8 (bug 1580565)
Backed out changeset c0849928f934 (bug 1580565)
Backed out changeset 3d4f155096be (bug 1580565)
Backed out changeset 108d5fb4418e (bug 1580565)
Backed out changeset d8dea951a032 (bug 1580565)
Backed out changeset f9ab41f29552 (bug 1580565)
Backed out changeset fd5d76304c09 (bug 1580565)
2020-04-22 21:51:17 +03:00
Nika Layzell 17375b9528 Bug 1580565 - Part 3: Simplify API for creating independent BCs, r=farre
There were previously a number of different APIs for creating BrowsingContext
instances. This simplifies them into two major cases: "CreateDetached", which
allows for creating BrowsingContexts which are related to other
BrowsingContexts, and "CreateIndependent" which creates new, fully unrelated,
browsing contexts.

Differential Revision: https://phabricator.services.mozilla.com/D71237
2020-04-22 15:48:20 +00:00
Dorel Luca 4914ab736f Backed out 7 changesets (bug 1580565) for Gecko-view failures in Test.crashParent. CLOSED TREE
Backed out changeset 7da9785ebb06 (bug 1580565)
Backed out changeset a80e177a91b2 (bug 1580565)
Backed out changeset 2cf821f2a6ea (bug 1580565)
Backed out changeset a30f158eba45 (bug 1580565)
Backed out changeset 276b131190a8 (bug 1580565)
Backed out changeset 3c15e4c600c4 (bug 1580565)
Backed out changeset bf8877cdb10f (bug 1580565)
2020-04-22 18:42:24 +03:00
Nika Layzell 2d6ee6dcd2 Bug 1580565 - Part 3: Simplify API for creating independent BCs, r=farre
There were previously a number of different APIs for creating BrowsingContext
instances. This simplifies them into two major cases: "CreateDetached", which
allows for creating BrowsingContexts which are related to other
BrowsingContexts, and "CreateIndependent" which creates new, fully unrelated,
browsing contexts.

Differential Revision: https://phabricator.services.mozilla.com/D71237
2020-04-22 03:21:55 +00:00
Bogdan Tara 8557fa3bcd Backed out 7 changesets (bug 1580565) for browser_entry_point_telemetry.js failures CLOSED TREE
Backed out changeset 12a4f3de76a8 (bug 1580565)
Backed out changeset 81d537df2dc1 (bug 1580565)
Backed out changeset b182e872c9d4 (bug 1580565)
Backed out changeset 0b4595b2c153 (bug 1580565)
Backed out changeset 4363e3a3d799 (bug 1580565)
Backed out changeset cbb14b2c7b33 (bug 1580565)
Backed out changeset 46b251848297 (bug 1580565)
2020-04-22 06:15:43 +03:00
Nika Layzell 3caf672787 Bug 1580565 - Part 3: Simplify API for creating independent BCs, r=farre
There were previously a number of different APIs for creating BrowsingContext
instances. This simplifies them into two major cases: "CreateDetached", which
allows for creating BrowsingContexts which are related to other
BrowsingContexts, and "CreateIndependent" which creates new, fully unrelated,
browsing contexts.

Differential Revision: https://phabricator.services.mozilla.com/D71237
2020-04-22 01:37:52 +00:00
Jonathan Watt dfec4151d6 Bug 1552966. Convert the printing code to stop using DocShellTree* classes. r=farre
Differential Revision: https://phabricator.services.mozilla.com/D56830
2020-02-14 16:31:01 +00:00
Kris Maglione 3af7a24cdd Bug 1582832: Part 3 - Correctly handle windowless BCs created for printing. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D61006
2020-02-06 19:08:06 +00:00
Kris Maglione d7e4043bb8 Bug 1582832: Part 1 - Make FrameLoader owner rather than DocShell responsible for discarding a BC. r=nika
There are all sorts of lifecycle issues which arise from making DocShell
responsible for discarding BrowsingContexts. In this particular bug, we tend
to run into them in cases where we create a BrowsingContext for a FrameLoader,
and then never create a DocShell for it, leading to it never being destroyed.
But there are myriad other issues as well.

This patch moves the responsibility for BrowsingContext lifecycle management
to the FrameLoader/FrameLoaderOwner, rather than the DocShell, which makes
things more consistent, and more closely aligns with spec-defined behavior.

Differential Revision: https://phabricator.services.mozilla.com/D59008
2020-02-06 19:07:56 +00:00
Ciure Andrei 4543ab54b3 Backed out changeset fd383a15ed4e (bug 1552966) for causing browser_printpreview.js to permafail CLOSED TREE 2019-12-14 17:45:23 +02:00
Jonathan Watt a3e542caeb Bug 1552966. Convert the printing code to stop using DocShellTree* classes. r=farre
Differential Revision: https://phabricator.services.mozilla.com/D56830
2019-12-13 14:16:15 +00:00
Nika Layzell 9f292597a2 Bug 1577711 - Part 1: Revert calling SetDocument earlier during clone from 1568055, r=smaug
This change was causing issues with images not displaying and iframes not
displaying correctly after multiple print preview calls.

Differential Revision: https://phabricator.services.mozilla.com/D44585
2019-09-05 14:55:11 +00:00
Nika Layzell 64f621aa8e Bug 1568055 - Part 1: SetDocument earlier in the clone operation for print, r=farre
This should ensure that the inner window for each document is set up correctly
before iframe elements are created in them during a static clone. Other,
non-static-clone cases are not affected because they cannot load subframes.

Differential Revision: https://phabricator.services.mozilla.com/D38931
2019-07-23 12:26:31 +00:00
Jonathan Watt d00e9c6477 Bug 1558180. Comment the mysterious OnPageHide() call in nsPrintJob and move it somewhere that makes sense. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D34347
2019-06-04 16:01:33 +01:00
Jonathan Watt 97b01fb154 Bug 1557434. Remove nsPrintObject::mPrintPreview. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D34134
2019-05-28 15:26:59 +01:00