Don't print-preview <noscript> unless script is really disabled. Bug 334944, r+sr=jst

This commit is contained in:
bzbarsky%mit.edu 2006-04-22 00:06:30 +00:00
Родитель 879f1173a1
Коммит ae1b7a2d2b
3 изменённых файлов: 19 добавлений и 3 удалений

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

@ -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);

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

@ -3589,13 +3589,23 @@ nsPrintEngine::TurnScriptingOn(PRBool aDoTurnOn)
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);
}
}