From 8360b93aa53c2e1f8a04e15b370cf330c3d261a5 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Thu, 1 Nov 2001 04:42:57 +0000 Subject: [PATCH] Fixing bug 103904. Don't let pref change callbacks run wild on documents that are partially torn down already. r=bzbarsky@mit.edu, sr=rpotts@netscape.com git-svn-id: svn://10.0.0.236/trunk@106922 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 23 +++++++++++++++----- mozilla/layout/html/base/src/nsPresShell.cpp | 23 +++++++++++++++----- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 4d6a6c11c1d..0878fdb2b0b 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -2001,6 +2001,22 @@ PresShell::ArePrefStyleRulesEnabled(PRBool& aEnabled) NS_IMETHODIMP PresShell::SetPreferenceStyleRules(PRBool aForceReflow) { + if (!mDocument) { + return NS_ERROR_NULL_POINTER; + } + + nsCOMPtr globalObj; + mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); + + // If the document doesn't have a global object there's no need to + // notify its presshell about changes to preferences since the + // document is in a state where it doesn't matter any more (see + // DocumentViewerImpl::Close()). + + if (!globalObj) { + return NS_ERROR_NULL_POINTER; + } + NS_PRECONDITION(mPresContext, "presContext cannot be null"); if (mPresContext) { nsresult result = NS_OK; @@ -2081,9 +2097,9 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) return result; - } else { - return NS_ERROR_NULL_POINTER; } + + return NS_ERROR_NULL_POINTER; } nsresult PresShell::ClearPreferenceStyleRules(void) @@ -3244,9 +3260,6 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend) result = GetPrimaryFrameFor(bodyContent, &frame); if (frame) { - PRInt32 offset; - PRInt32 offsetend; - PRBool beginFrameContent; PRInt8 outsideLimit = -1;//search from beginning nsPeekOffsetStruct pos; pos.mAmount = eSelectLine; diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 4d6a6c11c1d..0878fdb2b0b 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -2001,6 +2001,22 @@ PresShell::ArePrefStyleRulesEnabled(PRBool& aEnabled) NS_IMETHODIMP PresShell::SetPreferenceStyleRules(PRBool aForceReflow) { + if (!mDocument) { + return NS_ERROR_NULL_POINTER; + } + + nsCOMPtr globalObj; + mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); + + // If the document doesn't have a global object there's no need to + // notify its presshell about changes to preferences since the + // document is in a state where it doesn't matter any more (see + // DocumentViewerImpl::Close()). + + if (!globalObj) { + return NS_ERROR_NULL_POINTER; + } + NS_PRECONDITION(mPresContext, "presContext cannot be null"); if (mPresContext) { nsresult result = NS_OK; @@ -2081,9 +2097,9 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) return result; - } else { - return NS_ERROR_NULL_POINTER; } + + return NS_ERROR_NULL_POINTER; } nsresult PresShell::ClearPreferenceStyleRules(void) @@ -3244,9 +3260,6 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend) result = GetPrimaryFrameFor(bodyContent, &frame); if (frame) { - PRInt32 offset; - PRInt32 offsetend; - PRBool beginFrameContent; PRInt8 outsideLimit = -1;//search from beginning nsPeekOffsetStruct pos; pos.mAmount = eSelectLine;