Bug 1651117 part 1: Add nsIPrinter supportsColor attribute and Windows implementation. r=jwatt

Differential Revision: https://phabricator.services.mozilla.com/D85032
This commit is contained in:
Bob Owen 2020-08-03 11:45:35 +00:00
Родитель b32b1c0949
Коммит 57c231d365
6 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -17,6 +17,7 @@ function run() {
printerList.printers.forEach(printer => {
info(`Listing basic attributes for ${printer.name}:`);
info(`* supportsDuplex: ${printer.supportsDuplex}`);
info(`* supportsColor: ${printer.supportsColor}`);
})
ok(true, "Retrieved printer basic attributes successfully.");

Просмотреть файл

@ -23,4 +23,9 @@ interface nsIPrinter : nsISupports
* Whether this printer supports duplex printing.
*/
readonly attribute boolean supportsDuplex;
/**
* Whether this printer supports color printing.
*/
readonly attribute boolean supportsColor;
};

Просмотреть файл

@ -32,3 +32,11 @@ nsPrinter::GetSupportsDuplex(bool* aSupportsDuplex) {
*aSupportsDuplex = mSupportsDuplex;
return NS_OK;
}
NS_IMETHODIMP
nsPrinter::GetSupportsColor(bool* aSupportsColor) {
MOZ_ASSERT(aSupportsColor);
// Dummy implementation waiting platform specific one.
*aSupportsColor = false;
return NS_OK;
}

Просмотреть файл

@ -48,6 +48,14 @@ nsPrinterCUPS::GetSupportsDuplex(bool* aSupportsDuplex) {
return NS_OK;
}
NS_IMETHODIMP
nsPrinterCUPS::GetSupportsColor(bool* aSupportsColor) {
MOZ_ASSERT(aSupportsColor);
// Dummy implementation waiting platform specific one.
*aSupportsColor = false;
return NS_OK;
}
bool nsPrinterCUPS::Supports(const char* option, const char* value) const {
MOZ_ASSERT(mPrinterInfo);
return mShim.mCupsCheckDestSupported(CUPS_HTTP_DEFAULT, mPrinter,

Просмотреть файл

@ -134,3 +134,18 @@ nsPrinterWin::GetSupportsDuplex(bool* aSupportsDuplex) {
*aSupportsDuplex = mSupportsDuplex.value();
return NS_OK;
}
NS_IMETHODIMP
nsPrinterWin::GetSupportsColor(bool* aSupportsColor) {
MOZ_ASSERT(aSupportsColor);
if (mSupportsColor.isNothing()) {
// Note: this is a blocking call, which could be slow.
mSupportsColor =
Some(::DeviceCapabilitiesW(mName.get(), nullptr, DC_COLORDEVICE,
nullptr, nullptr) == 1);
}
*aSupportsColor = mSupportsColor.value();
return NS_OK;
}

Просмотреть файл

@ -28,6 +28,7 @@ class nsPrinterWin final : public nsIPrinter {
nsString mName;
nsTArray<RefPtr<nsIPaper>> mPaperList;
Maybe<bool> mSupportsDuplex;
Maybe<bool> mSupportsColor;
};
#endif // nsPrinterWin_h_