Bug 830278 - Allow disabling of selecting printing with mozdisallowselectionprint on the document element. r=roc

This commit is contained in:
Cameron McCormack 2013-01-29 15:59:55 +11:00
parent 6146dcbc98
commit 87fc6e7ab2
4 changed files with 15 additions and 2 deletions

View File

@ -37,6 +37,7 @@ GK_ATOM(mozframetype, "mozframetype")
GK_ATOM(mozallowfullscreen, "mozallowfullscreen")
GK_ATOM(moztype, "_moz-type")
GK_ATOM(mozdirty, "_moz_dirty")
GK_ATOM(mozdisallowselectionprint, "mozdisallowselectionprint")
GK_ATOM(mozdonotsend, "moz-do-not-send")
GK_ATOM(mozeditorbogusnode, "_moz_editor_bogus_node")
GK_ATOM(mozgeneratedcontentbefore, "_moz_generated_content_before")

View File

@ -3656,6 +3656,10 @@ nsDocumentViewer::Print(nsIPrintSettings* aPrintSettings,
if (mPrintEngine->HasPrintCallbackCanvas()) {
mBeforeAndAfterPrint = beforeAndAfterPrint;
}
dom::Element* root = mDocument->GetRootElement();
if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::mozdisallowselectionprint)) {
mPrintEngine->SetDisallowSelectionPrint(true);
}
rv = mPrintEngine->Print(aPrintSettings, aWebProgressListener);
if (NS_FAILED(rv)) {
OnDonePrinting();

View File

@ -236,7 +236,8 @@ nsPrintEngine::nsPrintEngine() :
mDebugFile(nullptr),
mLoadCounter(0),
mDidLoadDataForPrinting(false),
mIsDestroying(false)
mIsDestroying(false),
mDisallowSelectionPrint(false)
{
}
@ -559,7 +560,8 @@ nsPrintEngine::DoCommonPrint(bool aIsPrintPreview,
mPrt->mPrintSettings->SetHowToEnableFrameUI(nsIPrintSettings::kFrameEnableNone);
}
// Now determine how to set up the Frame print UI
mPrt->mPrintSettings->SetPrintOptions(nsIPrintSettings::kEnableSelectionRB, isSelection || mPrt->mIsIFrameSelected);
mPrt->mPrintSettings->SetPrintOptions(nsIPrintSettings::kEnableSelectionRB,
!mDisallowSelectionPrint && (isSelection || mPrt->mIsIFrameSelected));
nsCOMPtr<nsIDeviceContextSpec> devspec
(do_CreateInstance("@mozilla.org/gfx/devicecontextspec;1", &rv));

View File

@ -204,6 +204,11 @@ public:
return mIsCreatingPrintPreview;
}
void SetDisallowSelectionPrint(bool aDisallowSelectionPrint)
{
mDisallowSelectionPrint = aDisallowSelectionPrint;
}
protected:
nsresult CommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
@ -281,6 +286,7 @@ protected:
int32_t mLoadCounter;
bool mDidLoadDataForPrinting;
bool mIsDestroying;
bool mDisallowSelectionPrint;
nsresult AfterNetworkPrint(bool aHandleError);