зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
b32b1c0949
Коммит
57c231d365
|
@ -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_
|
||||
|
|
Загрузка…
Ссылка в новой задаче