Bug 1669409: Convert the nsIPrintSettings:kEnableSelectionRB flag into a boolean, since it's the only entry in a bitfield. r=jwatt,emilio

This was the last flag that the PrintOptions bitfield was tracking.

So, this patch is effectively converting that bitfield (and its alias
"PrintOptionsBits") into a new, simpler boolean field named
"isPrintSelectionRBEnabled".

Differential Revision: https://phabricator.services.mozilla.com/D92542
This commit is contained in:
Daniel Holbert 2020-10-07 00:36:51 +00:00
Родитель 94aa501946
Коммит 675e1e5b28
11 изменённых файлов: 28 добавлений и 89 удалений

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

@ -10084,7 +10084,6 @@ Gecko_IsDocumentBody
?StripTrackingIdentifiers@URLDecorationStripper@mozilla@@SA?AW4nsresult@@PAVnsIURI@@AAV?$nsTSubstring@D@@@Z
??1gfxWindowsNativeDrawing@@QAE@XZ
?RecvAddChild@SHEntryParent@dom@mozilla@@AAE_NPAVPSHEntryParent@23@ABHAB_NPAW4nsresult@@@Z
?SetPrintOptionsBits@nsPrintSettings@@UAG?AW4nsresult@@H@Z
?SetRealmPrincipals@JS@@YAXPAVRealm@1@PAUJSPrincipals@@@Z
?MarkAsBroken@nsHtml5TreeOpExecutor@@UAE?AW4nsresult@@W42@@Z
??$AppendElements@UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@VPrincipalInfo@ipc@mozilla@@UnsTArrayInfallibleAllocator@@@@IAEPAVPrincipalInfo@ipc@mozilla@@I@Z

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

@ -605,8 +605,7 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
}
// Now determine how to set up the Frame print UI
printData->mPrintSettings->SetPrintOptions(
nsIPrintSettings::kEnableSelectionRB,
printData->mPrintSettings->SetIsPrintSelectionRBEnabled(
!mDisallowSelectionPrint && printData->mSelectionRoot);
bool printingViaParent =

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

@ -624,10 +624,8 @@ var PrintEventHandler = {
numPages = settings.endPageRange - settings.startPageRange + 1;
}
// Update the settings print options on whether there is a selection.
settings.SetPrintOptions(
Ci.nsIPrintSettings.kEnableSelectionRB,
hasSelection
);
settings.isPrintSelectionRBEnabled = hasSelection;
document.dispatchEvent(
new CustomEvent("page-count", {
detail: { numPages, totalPages: totalPageCount },

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

@ -34,6 +34,7 @@ struct PrintData {
bool printBGImages;
bool honorPageRuleMargins;
bool showMarginGuides;
bool isPrintSelectionRBEnabled;
bool printSelectionOnly;
short printRange;
nsString title;
@ -67,7 +68,6 @@ struct PrintData {
int32_t duplex;
bool isInitializedFromPrinter;
bool isInitializedFromPrefs;
int32_t optionFlags;
/* Windows-specific things */
nsString driverName;

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

@ -363,8 +363,7 @@ static const char sHeaderFooterTags[][4] = {"", "&T", "&U", "&D", "&P", "&PT"};
mPrintSelectionOnlyCheckbox = [self checkboxWithLabel:"selectionOnly"
andFrame:NSMakeRect(156, 155, 0, 0)];
bool canPrintSelection;
mSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &canPrintSelection);
bool canPrintSelection = mSettings->GetIsPrintSelectionRBEnabled();
[mPrintSelectionOnlyCheckbox setEnabled:canPrintSelection];
if (mSettings->GetPrintSelectionOnly()) {

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

@ -197,9 +197,7 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsPIDOMWindowOuter* aParent,
// GTK+2.18 and above allow us to add a "Selection" option to the main
// settings screen, rather than adding an option on a custom tab like we must
// do on older versions.
bool canSelectText;
aSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB,
&canSelectText);
bool canSelectText = aSettings->GetIsPrintSelectionRBEnabled();
if (gtk_major_version > 2 ||
(gtk_major_version == 2 && gtk_minor_version >= 18)) {
useNativeSelection = true;

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

@ -62,9 +62,6 @@ interface nsIPrintSettings : nsISupports
const unsigned long kInitSaveAll = 0xFFFFFFFF;
/* Print Option Flags for Bit Field*/
const long kEnableSelectionRB = 0x00000001;
/* Print Range Enums */
const long kRangeAllPages = 0;
const long kRangeSpecifiedPageRange = 1;
@ -100,26 +97,6 @@ interface nsIPrintSettings : nsISupports
const short kDuplexHorizontal = 1;
const short kDuplexVertical = 2;
/**
* Set PrintOptions
*/
void SetPrintOptions(in int32_t aType, in boolean aTurnOnOff);
/**
* Get PrintOptions
*/
boolean GetPrintOptions(in int32_t aType);
/**
* Get PrintOptions Bit field
*/
int32_t GetPrintOptionsBits();
/**
* Set PrintOptions Bit field
*/
void SetPrintOptionsBits(in int32_t bits);
/**
* Get the page size in twips, considering the
* orientation (portrait or landscape).
@ -183,6 +160,10 @@ interface nsIPrintSettings : nsISupports
/** Whether to draw guidelines showing the margin settings */
[infallible] attribute boolean showMarginGuides;
/** Whether whether the "print selection" radio button should be enabled
* in the UI (i.e. whether there is an active selection) */
[infallible] attribute boolean isPrintSelectionRBEnabled;
/** Whether to only print the selected nodes */
[infallible] attribute boolean printSelectionOnly;

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

@ -16,8 +16,7 @@
NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings)
nsPrintSettings::nsPrintSettings()
: mPrintOptions(0L),
mPrintRange(kRangeAllPages),
: mPrintRange(kRangeAllPages),
mStartPageNum(1),
mEndPageNum(1),
mScaling(1.0),
@ -30,6 +29,7 @@ nsPrintSettings::nsPrintSettings()
mShowPrintProgress(true),
mShowMarginGuides(false),
mHonorPageRuleMargins(true),
mIsPrintSelectionRBEnabled(false),
mPrintSelectionOnly(false),
mPrintPageDelay(50),
mPaperWidth(8.5),
@ -470,47 +470,6 @@ NS_IMETHODIMP nsPrintSettings::SetDocURL(const nsAString& aDocURL) {
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsImpl.h
* @update 1/12/01 rods
*/
NS_IMETHODIMP
nsPrintSettings::GetPrintOptions(int32_t aType, bool* aTurnOnOff) {
NS_ENSURE_ARG_POINTER(aTurnOnOff);
*aTurnOnOff = mPrintOptions & aType ? true : false;
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsImpl.h
* @update 1/12/01 rods
*/
NS_IMETHODIMP
nsPrintSettings::SetPrintOptions(int32_t aType, bool aTurnOnOff) {
if (aTurnOnOff) {
mPrintOptions |= aType;
} else {
mPrintOptions &= ~aType;
}
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsImpl.h
* @update 1/12/01 rods
*/
NS_IMETHODIMP
nsPrintSettings::GetPrintOptionsBits(int32_t* aBits) {
NS_ENSURE_ARG_POINTER(aBits);
*aBits = mPrintOptions;
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettings::SetPrintOptionsBits(int32_t aBits) {
mPrintOptions = aBits;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetHeaderStrLeft(nsAString& aTitle) {
aTitle = mHeaderStrs[0];
return NS_OK;
@ -615,6 +574,17 @@ NS_IMETHODIMP nsPrintSettings::SetHonorPageRuleMargins(bool aHonor) {
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetIsPrintSelectionRBEnabled(
bool* aIsPrintSelectionRBEnabled) {
*aIsPrintSelectionRBEnabled = mIsPrintSelectionRBEnabled;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::SetIsPrintSelectionRBEnabled(
bool aIsPrintSelectionRBEnabled) {
mIsPrintSelectionRBEnabled = aIsPrintSelectionRBEnabled;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetPrintSelectionOnly(bool* aResult) {
*aResult = mPrintSelectionOnly;
return NS_OK;
@ -791,7 +761,6 @@ nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) {
mMargin = rhs.mMargin;
mEdge = rhs.mEdge;
mUnwriteableMargin = rhs.mUnwriteableMargin;
mPrintOptions = rhs.mPrintOptions;
mScaling = rhs.mScaling;
mPrintBGColors = rhs.mPrintBGColors;
mPrintBGImages = rhs.mPrintBGImages;
@ -805,6 +774,7 @@ nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) {
mShowPrintProgress = rhs.mShowPrintProgress;
mShowMarginGuides = rhs.mShowMarginGuides;
mHonorPageRuleMargins = rhs.mHonorPageRuleMargins;
mIsPrintSelectionRBEnabled = rhs.mIsPrintSelectionRBEnabled;
mPrintSelectionOnly = rhs.mPrintSelectionOnly;
mPaperId = rhs.mPaperId;
mPaperWidth = rhs.mPaperWidth;

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

@ -78,8 +78,6 @@ class nsPrintSettings : public nsIPrintSettings {
nsIntMargin mEdge;
nsIntMargin mUnwriteableMargin;
int32_t mPrintOptions;
// scriptable data members
int16_t mPrintRange;
int32_t mStartPageNum; // only used for ePrintRange_SpecifiedRange
@ -95,6 +93,7 @@ class nsPrintSettings : public nsIPrintSettings {
bool mShowPrintProgress;
bool mShowMarginGuides;
bool mHonorPageRuleMargins;
bool mIsPrintSelectionRBEnabled;
bool mPrintSelectionOnly;
int32_t mPrintPageDelay;

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

@ -115,6 +115,7 @@ nsPrintSettingsService::SerializeToPrintData(nsIPrintSettings* aSettings,
data->honorPageRuleMargins() = aSettings->GetHonorPageRuleMargins();
data->showMarginGuides() = aSettings->GetShowMarginGuides();
data->isPrintSelectionRBEnabled() = aSettings->GetIsPrintSelectionRBEnabled();
data->printSelectionOnly() = aSettings->GetPrintSelectionOnly();
aSettings->GetPrintRange(&data->printRange());
@ -159,8 +160,6 @@ nsPrintSettingsService::SerializeToPrintData(nsIPrintSettings* aSettings,
aSettings->GetIsInitializedFromPrinter(&data->isInitializedFromPrinter());
aSettings->GetIsInitializedFromPrefs(&data->isInitializedFromPrefs());
aSettings->GetPrintOptionsBits(&data->optionFlags());
// Initialize the platform-specific values that don't
// default-initialize, so that we don't send uninitialized data over
// IPC (which leads to valgrind warnings, and, for bools, fatal
@ -215,6 +214,7 @@ nsPrintSettingsService::DeserializeToPrintSettings(const PrintData& data,
settings->SetPrintBGImages(data.printBGImages());
settings->SetHonorPageRuleMargins(data.honorPageRuleMargins());
settings->SetShowMarginGuides(data.showMarginGuides());
settings->SetIsPrintSelectionRBEnabled(data.isPrintSelectionRBEnabled());
settings->SetPrintSelectionOnly(data.printSelectionOnly());
settings->SetPrintRange(data.printRange());
@ -261,8 +261,6 @@ nsPrintSettingsService::DeserializeToPrintSettings(const PrintData& data,
settings->SetIsInitializedFromPrinter(data.isInitializedFromPrinter());
settings->SetIsInitializedFromPrefs(data.isInitializedFromPrefs());
settings->SetPrintOptionsBits(data.optionFlags());
return NS_OK;
}

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

@ -215,9 +215,7 @@ static nsresult ShowNativePrintDialog(HWND aHWnd,
PD_ALLPAGES | PD_RETURNIC | PD_USEDEVMODECOPIESANDCOLLATE | PD_COLLATE;
// if there is a current selection then enable the "Selection" radio button
bool isOn;
aPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
if (!isOn) {
if (!aPrintSettings->GetIsPrintSelectionRBEnabled()) {
prntdlg.Flags |= PD_NOSELECTION;
}