зеркало из https://github.com/mozilla/pjs.git
Don't print-preview <noscript> unless script is really disabled. Bug 334944, r+sr=jst
This commit is contained in:
Родитель
879f1173a1
Коммит
ae1b7a2d2b
|
@ -650,6 +650,7 @@ GK_ATOM(screen, "screen")
|
|||
GK_ATOM(screenX, "screenX")
|
||||
GK_ATOM(screenY, "screenY")
|
||||
GK_ATOM(script, "script")
|
||||
GK_ATOM(scriptEnabledBeforePrintPreview, "scriptEnabledBeforePrintPreview")
|
||||
GK_ATOM(scrollbar, "scrollbar")
|
||||
GK_ATOM(scrollbarbutton, "scrollbarbutton")
|
||||
GK_ATOM(scrollbox, "scrollbox")
|
||||
|
|
|
@ -2335,7 +2335,12 @@ PresShell::SetPrefNoScriptRule()
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mDocument->IsScriptEnabled()) {
|
||||
PRBool scriptEnabled = mDocument->IsScriptEnabled() ||
|
||||
(mPresContext->Type() == nsPresContext::eContext_PrintPreview &&
|
||||
NS_PTR_TO_INT32(mDocument->GetProperty(
|
||||
nsLayoutAtoms::scriptEnabledBeforePrintPreview)));
|
||||
|
||||
if (scriptEnabled) {
|
||||
if (!mPrefStyleSheet) {
|
||||
rv = CreatePreferenceStyleSheet();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -3588,14 +3588,24 @@ nsPrintEngine::TurnScriptingOn(PRBool aDoTurnOn)
|
|||
for (PRInt32 i=0;i<prt->mPrintDocList->Count();i++) {
|
||||
nsPrintObject* po = (nsPrintObject*)prt->mPrintDocList->ElementAt(i);
|
||||
NS_ASSERTION(po, "nsPrintObject can't be null!");
|
||||
|
||||
nsIDocument* doc = po->mDocument;
|
||||
|
||||
// get the script global object
|
||||
nsIScriptGlobalObject *scriptGlobalObj =
|
||||
po->mDocument->GetScriptGlobalObject();
|
||||
nsIScriptGlobalObject *scriptGlobalObj = doc->GetScriptGlobalObject();
|
||||
|
||||
if (scriptGlobalObj) {
|
||||
nsIScriptContext *scx = scriptGlobalObj->GetContext();
|
||||
NS_ASSERTION(scx, "Can't get nsIScriptContext");
|
||||
if (aDoTurnOn) {
|
||||
doc->DeleteProperty(nsLayoutAtoms::scriptEnabledBeforePrintPreview);
|
||||
} else {
|
||||
// Stash the current value of IsScriptEnabled on the document,
|
||||
// so that layout code running in print preview doesn't get
|
||||
// confused.
|
||||
doc->SetProperty(nsLayoutAtoms::scriptEnabledBeforePrintPreview,
|
||||
NS_INT32_TO_PTR(doc->IsScriptEnabled()));
|
||||
}
|
||||
scx->SetScriptsEnabled(aDoTurnOn, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче