Commit Graph
49 Commits
Author SHA1 Message Date
nicklas boman 4114a8d7f7 Bug 1724649 - Followup to remove #include plstr.h r=necko-reviewers,xpcom-reviewers,valentin,nika
Differential Revision: https://phabricator.services.mozilla.com/D177690
2023-05-15 14:53:02 +00:00
Emily McDonough 02da771a99 Bug 1826872 Part 2 - Move CUPS printer dest into CUPSPrinterInfo for nsPrinterCUPS r=dholbert
This puts all CUPS data into one structure, refactors the locking of this
data, and and simplifies logic for determining the connection to use in
TryEnsurePrinterInfo.

Differential Revision: https://phabricator.services.mozilla.com/D174925
2023-04-10 21:11:28 +00:00
Emily McDonough 2324fbccba Bug 1826872 Part 1 - Tiny consistency cleanup in nsPrinterCUPS r=dholbert
Consistently use type name for PrinterInfoLock, and don't place mPrinterInfo
into local variables in nsPrinterCUPS.

Differential Revision: https://phabricator.services.mozilla.com/D174984
2023-04-10 21:11:28 +00:00
Emily McDonough f028d6c913 Bug 1746956 - Assume that a CUPS server name and hostname are not textually equal when the hostname might have been normalized to "localhost" r=dholbert
This accounts for a specific situation where our check for Bug 1691347 was not
quite identical to the code in CUPS.

In httpGetHostname, there are some cases where the result is "localhost" rather
than `http->hostname`:
https://github.com/apple/cups/blob/2201569857f225c9874bfae19713ffb2f4bdfdeb/cups/http-addr.c#L794-L818

We will now assume that if the result is "localhost" then this could have
occurred. This change might block some printers that would otherwise work
properly, but eventually this fix can be placed behind a CUPS version check.

Differential Revision: https://phabricator.services.mozilla.com/D137903
2022-02-05 00:39:04 +00:00
Stephen A Pohl d42bf8fe6b Bug 1719427: Refactor scrollbar drawing code across platforms. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D129265
2021-11-15 12:39:38 +00:00
criss 317421bcb1 Backed out 4 changesets (bug 1719427) for causing build bustages. CLOSED TREE
Backed out changeset d6948ef7f495 (bug 1719427)
Backed out changeset 4df7017f6bc9 (bug 1719427)
Backed out changeset 8c5bb08f80e9 (bug 1719427)
Backed out changeset e32004dd2014 (bug 1719427)
2021-11-15 13:46:20 +02:00
Stephen A Pohl b1a6c42698 Bug 1719427: Refactor scrollbar drawing code across platforms. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D129265
2021-11-15 11:15:54 +00:00
Emily McDonough cfa836b68f Bug 1691347 - Work around a null argument bug in _platform_strstr in CUPS. r=dholbert
This is just a large conditional to check for the specific branches taken
that would result in the null string. The path in CUPS is as follows:

In cupsCopyDestInfo, CUPS_DEST_FLAG_DEVICE is set when the connection is not
null (same as CUPS_HTTP_DEFAULT), the print server is not the same as our
hostname and is not path-based (starts with a '/'), or the IPP port is
different than the global server IPP port.

https://github.com/apple/cups/blob/c9da6f63b263faef5d50592fe8cf8056e0a58aa2/cups/dest-options.c#L718-L722

In _cupsGetDestResource, CUPS fetches the IPP options "printer-uri-supported"
and "device-uri". Importantly, IPP options are returned as null when missing.

https://github.com/apple/cups/blob/23c45db76a8520fd6c3b1d9164dbe312f1ab1481/cups/dest.c#L1138-L1141

If the CUPS_DEST_FLAG_DEVICE is set or the "printer-uri-supported" option is
not set, CUPS checks for "._tcp" in the "device-uri" option without doing a
NULL-check first.

https://github.com/apple/cups/blob/23c45db76a8520fd6c3b1d9164dbe312f1ab1481/cups/dest.c#L1144

If we find that those branches will be taken, don't actually fetch the CUPS
data and instead just return an empty printer info.

Differential Revision: https://phabricator.services.mozilla.com/D128529
2021-10-22 22:55:25 +00:00
Emilio Cobos Álvarez c257817db4 Bug 1701019 - Add support for cups 1.6+ to the printing code. r=jwatt
Just make some functions optional and deal with them not being there.

We won't have localized media names and per-printer paper lists, but
that seems fine, it's an obvious improvement over not showing printers.

Also, add some logging so next time we need to debug something like this
we can figure out without having to rebuild.

Differential Revision: https://phabricator.services.mozilla.com/D110032
2021-03-29 10:08:44 +00:00
Emily McDonough e3eb6c864a Bug 1676976 - Have nsPrinterCUPS::TryEnsurePrinterInfo return a DataMutex::AutoLock r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96937
2020-11-13 19:58:25 +00:00
Emilio Cobos Álvarez 652242fbf0 Bug 1676527 - Allow extending the CUPS monochrome print setting list without rebuilding. r=nordzilla
Mostly for debugging / diagnosing purposes. This is easier than asking
people to try builds from try or building Firefox.

Differential Revision: https://phabricator.services.mozilla.com/D96648
2020-11-11 19:00:00 +00:00
Emily McDonough 0f7c87594c Bug 1663652 part 2 - Add combined printerInfo method to nsPrinterCUPS r=emilio
Since we no longer are using the PaperList or CreateDefaultSettings methods on
nsPrinterBase, and we can remove them from nsPrinterBase.

This should dramatically improve latency when the remote printer is not
available, or when the print server is slower. In the best-case scenario it may
increase the latency to displaying the print preview somewhat.

Differential Revision: https://phabricator.services.mozilla.com/D94482
2020-11-03 20:35:38 +00:00
Emilio Cobos Álvarez 9d5e8e1b16 Bug 1672625 - Make monochrome support on GTK work like on Mac. r=jfkthame
We do it in nsDeviceContextSpecG since that's what actually consumes the
settings. On GTK the options need to be prefixed by cups- for some
reason in order to work, so factor out a macro listing the options and
do the NSString / cups- prefixing in the platform specific places.

Differential Revision: https://phabricator.services.mozilla.com/D94479
2020-10-27 16:23:26 +00:00
Emilio Cobos Álvarez 1c62cb36d3 Bug 1670943 - Add monochrome support for OSX. r=jwatt,jfkthame
See comments for fun.

Differential Revision: https://phabricator.services.mozilla.com/D93527
2020-10-23 11:58:42 +00:00
Emily McDonough dbbdfe5709 Bug 1667486 part 2 - Use our own localization for nsPrinterCUPS paper sizes when possible r=emilio
This should be able to avoid creating a printer-specific HTTP connection in
nsPrinterCUPS::DefaultSettings when the paper size is a PWG-recognized size.

The current maximum error when comparing paper sizes is 4 points. This may need
to be revised later.

Differential Revision: https://phabricator.services.mozilla.com/D91497
2020-10-13 21:52:04 +00:00
Erik Nordin 71f8447546 Bug 1666918 - Prevent Duplicate Paper Sizes Returned From CUPS r=emilio
CUPS occasionally returns duplicate paper sizes, especially on
older versions of Ubuntu. This patch utilizes a hash set to
skip over any duplciate paper sizes, ensuring that the final list
contains only unique sizes.

These duplicate checks are currently being done on the front end,
and this patch will allow us to remove them.

Differential Revision: https://phabricator.services.mozilla.com/D91215
2020-09-30 18:37:50 +00:00
Erik Nordin f0a40f1f65 Bug 1662946 - Fix Paper List Retrieval For Older Versions of Ubuntu r=emilio
- Rename EnsurePrinterInfo to TryEnsurePrinterInfo to reflect the fact that it can fail to populate the printer info.
- Add argument to TryEnsurePrinterInfo to accept a connection other than the default.
- Allow TryEnsurePrinterInfo to try once with the default connection and once with an established connection.
- Use an established connection to retrieve the paper list information.

Differential Revision: https://phabricator.services.mozilla.com/D91193
2020-09-24 22:01:43 +00:00
Erik Nordin 88b247ff79 Bug 1666964 - Retrieve Printer Default Media Through IPP Attribute r=hiro
cupsGetDestMediaDefault seems to not be returning the correct defaults,
so this patch retrieves the default media through the IPP attribute
instead, in hopes that this will provide more accurate defaults.

Differential Revision: https://phabricator.services.mozilla.com/D91376
2020-09-25 02:00:46 +00:00
Jonathan Watt bc33ceb163 Bug 1665618. Fallback to allowing printing in color on failure to get printer capabilities. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D90546
2020-09-17 12:14:25 +00:00
Jonathan Kew f11c221255 Bug 1662538 - patch 1 - Make nsIPaper expose a non-localizable .id in addition to a localizable .name attribute. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D90073
2020-09-17 20:05:08 +00:00
Emily McDonough 8a4720bb6e Bug 1659807 - Add nsIPrinter.systemName and nsIPrinterList.getPrinterBySystemName r=emilio
This also renames nsIPrinterList.getNamedPrinter to nsIPrinter.getPrinterByName
for consistency.

This is cheaper to lookup on platforms that use CUPS and do not show the Unix
name for printers. This only applies to OS X at the present.

Differential Revision: https://phabricator.services.mozilla.com/D90201
2020-09-15 21:23:27 +00:00
Emily McDonough 0acf01fc24 Bug 1664172 - Remove the MOZ_RELEASE_ASSERT on the CUPS dinfo r=emilio
Add a separate field to CUPSPrinterInfo to track if we attempted to fetch the
printer info before.

This should be safe, as all the CUPS calls internally check for a null-dinfo
and we will detect the error at that point.

Differential Revision: https://phabricator.services.mozilla.com/D89847
2020-09-11 00:36:17 +00:00
Emily McDonough c353cb6ad6 Bug 1661157 part 2 - Fetch CUPS printer info as it is needed by nsPrinterCUPS r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D89655
2020-09-09 23:56:13 +00:00
Emily McDonough 6e4a576af9 Bug 1661157 part 1 - Wrap nsPrinterCUPS::mPrinterInfo in a data mutex r=emilio
This may also help with the crashes in bug 1663410 and bug 1663412

Differential Revision: https://phabricator.services.mozilla.com/D89654
2020-09-09 23:51:59 +00:00
Emilio Cobos Álvarez 5bb7c8a858 Bug 1661720 - Move monochrome detection to nsIPrinter. r=bobowen
This moves the special cases to the printing platform code instead
(where it belongs).

The SupportsMonochrome() implementation is the only thing that I found
to work for the "Microsoft Print to PDF" driver, but other similar
drivers like XPS still claim to support monochrome (even though it's not
true). This should avoid the UI getting in a bad state as described in
the bug though, so may be better?

Depends on D89306

Differential Revision: https://phabricator.services.mozilla.com/D89312
2020-09-07 18:58:48 +00:00
Emily McDonough ae26580fcf Bug 1662518 part 3 - Use a dummy value for nsPrinterCUPS::SupportsColor if CUPS is older than 2.2 r=emilio,jwatt
Differential Revision: https://phabricator.services.mozilla.com/D89036
2020-09-02 23:49:08 +00:00
Emily McDonough 41b97cce63 Bug 1661785 - Check for both CUPS_PRINT_COLOR_MODE_COLOR and CUPS_PRINT_COLOR_MODE_AUTO for CUPS color printing support. r=nordzilla
This may fix bug 1660658. It's pretty harmless if it turns out to be redundant
to make this check.

Differential Revision: https://phabricator.services.mozilla.com/D88654
2020-08-28 19:15:21 +00:00
Erik Nordin 1fb98f690a Bug 1660589 - Localize paper names only on macOS and not Linux r=jwatt
Paper names should be localized on macOS, but on linux we want to use
the PWG standardized media name.

Differential Revision: https://phabricator.services.mozilla.com/D87936
2020-08-22 01:43:33 +00:00
Erik Nordin 61c975eaa2 Bug 1658299 - Part 1: Add createDefaultSettings() to nsIPrinter for CUPS r=jwatt,emilio,geckoview-reviewers,owlish
This patch adds a createDefaultSettings() method to nsIPrinter to
initialize a default print settings object specific to that printer.
It implements the functionality for Linux and macOS but adds only stubs
for Windows.

Differential Revision: https://phabricator.services.mozilla.com/D87125
2020-08-20 06:11:08 +00:00
Bogdan Tara 7ba9bd2076 Backed out changeset ebf8dfa204ea (bug 1658299) for test_printer_default_settings.html failures CLOSED TREE 2020-08-20 05:36:37 +03:00
Erik Nordin f6c1ab323d Bug 1658299 - Part 1: Add createDefaultSettings() to nsIPrinter for CUPS r=jwatt,emilio,geckoview-reviewers,owlish
This patch adds a createDefaultSettings() method to nsIPrinter to
initialize a default print settings object specific to that printer.
It implements the functionality for Linux and macOS but adds only stubs
for Windows.

Differential Revision: https://phabricator.services.mozilla.com/D87125
2020-08-20 00:23:59 +00:00
Emily McDonough 8b951c265a Bug 1658073 - Add SupportsCollation to nsIPrinter r=jwatt,emilio
Differential Revision: https://phabricator.services.mozilla.com/D86643
2020-08-14 20:41:59 +00:00
Erik Nordin 6dbfcbec6b Bug 1657518 - Clean up nsCUPSPrinter GetName() Functionality r=emilio
- Add cupsGetOption function support to CUPSShim
- Improve performance on GetName() function to not copy string twice.
- Unify implementation of `GetDisplayNameForPrinter()`

Differential Revision: https://phabricator.services.mozilla.com/D86114
2020-08-10 19:22:27 +00:00
Emilio Cobos Álvarez f88dd96efe Bug 1657363 - Make nsIPrinterList.printers return a promise. r=jwatt
I intentionally removed the "move the default printer to the front" in
windows because that's not a guarantee that we provide in CUPS, but lmk
if you want it back.

I have zero idea about why the GlobalPrinters code was so ridiculously
complex.

Depends on D86396

Differential Revision: https://phabricator.services.mozilla.com/D86397
2020-08-09 22:05:57 +00:00
Emilio Cobos Álvarez da83573555 Bug 1657363 - Fix Linux / OSX builds without the remaining patches.
CLOSED TREE

MANUAL PUSH: Bustage fix.
2020-08-07 22:48:49 +02:00
Emily McDonough eb3b7966bd Bug 1651117 Part 2 - Add color information for CUPS printers r=nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D86258
2020-08-06 20:57:43 +00:00
Erik Nordin 533b0d91a7 Bug 1656587 - Retrieve Default Printer Name Using CUPS r=AlaskanEmily
Differential Revision: https://phabricator.services.mozilla.com/D85628
2020-08-06 17:26:04 +00:00
Erik Nordin 0fd880914c Bug 1656379 - Rename nsCUPSShim function pointers r=AlaskanEmily,jwatt
Differential Revision: https://phabricator.services.mozilla.com/D85491
2020-08-06 17:01:21 +00:00
Cosmin Sabou b0b5f8ccd6 Backed out 2 changesets (bug 1656379, bug 1656587) for linux Hazard bustages.
Backed out changeset 451369452f15 (bug 1656587)
Backed out changeset 670195cb59f8 (bug 1656379)
2020-08-06 10:36:51 +03:00
Erik Nordin 4459b4d1d0 Bug 1656587 - Retrieve Default Printer Name Using CUPS r=AlaskanEmily
Differential Revision: https://phabricator.services.mozilla.com/D85628
2020-08-06 04:28:01 +00:00
Erik Nordin 32a01b5194 Bug 1656384 - Retrieve Printers using CUPSPrinterList on macOS r=jwatt,AlaskanEmily
Differential Revision: https://phabricator.services.mozilla.com/D85623
2020-08-06 01:42:13 +00:00
Erik Nordin 550e674a12 Bug 1656379 - Rename nsCUPSShim function pointers r=AlaskanEmily,jwatt
Differential Revision: https://phabricator.services.mozilla.com/D85491
2020-08-06 00:12:07 +00:00
Emilio Cobos Álvarez 4bfe2ce33f Bug 1655558 - Retrieve the paper margins lazily on Windows. r=jwatt,bobowen
This is no worse than what we were doing.

In the future, instead of just querying the margin we may want to query
extra information that requires a DC in windows too or what not, for
example.

Differential Revision: https://phabricator.services.mozilla.com/D85919
2020-08-05 11:26:13 +00:00
Emilio Cobos ÁlvarezandErik Nordin 913fa9c769 Bug 1655558 - Retrieve paper information from CUPS, and convert paperList to an async attribute. r=jwatt
This builds on top of bug 1656146 to compute the page information on a
background task, and return it via a promise.

Co-Authored-By: Erik Nordin <[email protected]>

Differential Revision: https://phabricator.services.mozilla.com/D85865
2020-08-05 01:24:49 +00:00
Emilio Cobos ÁlvarezandJonathan Watt 4c9ac50688 Bug 1656146 - Introduce nsPrinterBase, and add facilities for async attributes queried in a background thread. r=heycam
While at it, properly CC the printer classes, as they're going to hold
promises and it's very easy to introduce leaks otherwise.

Co-Authored-By: Jonathan Watt <[email protected]>

Differential Revision: https://phabricator.services.mozilla.com/D85791
2020-08-04 12:06:37 +00:00
Brindusan Cristian d7c8fb65a1 Backed out changeset 5913d9f4c3e9 (bug 1655558) for build bustages at nsPaperCUPS.h:9:10. CLOSED TREE 2020-08-04 08:41:27 +03:00
Erik Nordin 0ff8f9b02c Bug 1655558 - Part 1 Retrieve Paper Information from CUPS on macOS r=jwatt
Retrieve paper size information directy from CUPS.

- Add unwriteable margins tests.
- Rename nsPaper to nsPaperCUPS.
- Add new functionality to nsCUPSShim.
- Retrieve paper info from CUPS

Differential Revision: https://phabricator.services.mozilla.com/D85211
2020-08-04 04:43:47 +00:00
Bob Owen 4aa0ab71b4 Bug 1651117 part 1: Add nsIPrinter supportsColor attribute and Windows implementation. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D85032
2020-08-03 11:45:35 +00:00
Emily McDonough c206c48574 Bug 1654678 Part 3 - Create nsPrinterCUPS and use it on OS X for printer enumeration r=nordzilla
This leaves the nsPrinter for the time being, as it will also need to be
replaced on GTK before it can be removed.

While messing with widget/moz.build, also move the new printing source to be
controlled by the NS_PRINTING flag.

Differential Revision: https://phabricator.services.mozilla.com/D85092
2020-07-29 18:02:21 +00:00