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
This commit is contained in:
pollmann%netscape.com 2001-04-24 23:25:09 +00:00
parent 9749df27cb
commit aa4cf79dbe
2 changed files with 22 additions and 14 deletions

View File

@ -2352,24 +2352,25 @@ HTMLContentSink::Init(nsIDocument* aDoc,
mWebShell = aContainer;
NS_ADDREF(aContainer);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
NS_ASSERTION(docShell,"oops no docshell!");
if (docShell) {
PRBool enabled;
docShell->GetAllowJavascript(&enabled);
PRBool enabled = PR_TRUE;
nsCOMPtr<nsIPref> 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<nsIDocShell> 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))) {

View File

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