From aa4cf79dbecf34587dd8864652e158840d3f56dd Mon Sep 17 00:00:00 2001 From: "pollmann%netscape.com" Date: Tue, 24 Apr 2001 23:25:09 +0000 Subject: [PATCH] Bug 77227: Check if javascript is enabled every page load instead of caching the pref value in the DocShell, r=harishd@netscape.com, sr=brendan@mozilla.org git-svn-id: svn://10.0.0.236/trunk@93037 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLContentSink.cpp | 35 ++++++++++++------- mozilla/docshell/base/nsDocShell.cpp | 1 - 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 8147b8a7cdf..37fe48fa95d 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -2352,24 +2352,25 @@ HTMLContentSink::Init(nsIDocument* aDoc, mWebShell = aContainer; NS_ADDREF(aContainer); - nsCOMPtr docShell(do_QueryInterface(mWebShell)); - NS_ASSERTION(docShell,"oops no docshell!"); - if (docShell) { - PRBool enabled; - - docShell->GetAllowJavascript(&enabled); + PRBool enabled = PR_TRUE; + nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID)); + NS_ASSERTION(prefs, "oops no prefs!"); + if (prefs) { + prefs->GetBoolPref("javascript.enabled", &enabled); if (enabled) { mFlags |= NS_SINK_FLAG_SCRIPT_ENABLED; } - + } + + nsCOMPtr docShell(do_QueryInterface(mWebShell)); + NS_ASSERTION(docShell,"oops no docshell!"); + if (docShell) { docShell->GetAllowSubframes(&enabled); if (enabled) { mFlags |= NS_SINK_FLAG_FRAMES_ENABLED; } } - NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); - if (NS_FAILED(rv)) { MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n")); MOZ_TIMER_STOP(mWatch); @@ -2377,10 +2378,14 @@ HTMLContentSink::Init(nsIDocument* aDoc, } mNotifyOnTimer = PR_TRUE; - prefs->GetBoolPref("content.notify.ontimer", &mNotifyOnTimer); + if (prefs) { + prefs->GetBoolPref("content.notify.ontimer", &mNotifyOnTimer); + } mBackoffCount = -1; // never - prefs->GetIntPref("content.notify.backoffcount", &mBackoffCount); + if (prefs) { + prefs->GetIntPref("content.notify.backoffcount", &mBackoffCount); + } // The mNotificationInterval has a dramatic effect on how long it // takes to initially display content for slow connections. @@ -2390,10 +2395,14 @@ HTMLContentSink::Init(nsIDocument* aDoc, // it starts to impact page load performance. // see bugzilla bug 72138 for more info. mNotificationInterval = 250000; - prefs->GetIntPref("content.notify.interval", &mNotificationInterval); + if (prefs) { + prefs->GetIntPref("content.notify.interval", &mNotificationInterval); + } mMaxTextRun = 8192; - prefs->GetIntPref("content.maxtextrun", &mMaxTextRun); + if (prefs) { + prefs->GetIntPref("content.maxtextrun", &mMaxTextRun); + } nsIHTMLContentContainer* htmlContainer = nsnull; if (NS_SUCCEEDED(aDoc->QueryInterface(NS_GET_IID(nsIHTMLContentContainer), (void**)&htmlContainer))) { diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index db160d76b0a..02933aa004c 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -1706,7 +1706,6 @@ NS_IMETHODIMP nsDocShell::Create() // so read it in once here and be done with it... mPrefs->GetBoolPref("network.protocols.useSystemDefaults", &mUseExternalProtocolHandler); mPrefs->GetBoolPref("browser.target_new_blocked", &mDisallowPopupWindows); - mPrefs->GetBoolPref("javascript.enabled", &mAllowJavascript); mPrefs->GetBoolPref("browser.frames.enabled", &mAllowSubframes); return NS_OK;