From a59b4f2a9d80a8ded5ebf5cd27322588d8570467 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Mon, 3 Aug 1998 23:39:16 +0000 Subject: [PATCH] Fixed the release problem on shell and doc and added a default paramenter to Display Selection --- layout/base/src/nsFrame.cpp | 31 ++++++++++++++++++++++--------- layout/base/src/nsFrame.h | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/layout/base/src/nsFrame.cpp b/layout/base/src/nsFrame.cpp index 1245098976f..27472727b24 100644 --- a/layout/base/src/nsFrame.cpp +++ b/layout/base/src/nsFrame.cpp @@ -480,13 +480,23 @@ NS_METHOD nsFrame::LastChild(nsIFrame*& aLastChild) const } -PRBool nsFrame::DisplaySelection(nsIPresContext& aPresContext) +PRBool nsFrame::DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn) { - nsIPresShell *shell = aPresContext.GetShell(); - nsIDocument *doc = shell->GetDocument(); - PRBool result = doc->GetDisplaySelection(); - NS_RELEASE(shell); - NS_RELEASE(doc); + PRBool result = PR_FALSE; + + nsIPresShell *shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIDocument *doc = shell->GetDocument(); + if (nsnull != doc) { + result = doc->GetDisplaySelection(); + if (isOkToTurnOn && !result) { + doc->SetDisplaySelection(PR_TRUE); + result = PR_TRUE; + } + NS_RELEASE(doc); + } + NS_RELEASE(shell); + } return result; } @@ -558,8 +568,11 @@ NS_METHOD nsFrame::HandleEvent(nsIPresContext& aPresContext, mContent->HandleDOMEvent(aPresContext, (nsEvent*)aEvent, nsnull, DOM_EVENT_INIT, aEventStatus); } - if (DisplaySelection(aPresContext) == PR_FALSE) - return NS_OK; + if (DisplaySelection(aPresContext) == PR_FALSE) { + if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) { + return NS_OK; + } + } if(nsEventStatus_eIgnore == aEventStatus) { if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection || @@ -597,7 +610,7 @@ NS_METHOD nsFrame::HandlePress(nsIPresContext& aPresContext, nsEventStatus& aEventStatus, nsFrame * aFrame) { - if (DisplaySelection(aPresContext) == PR_FALSE) + if (DisplaySelection(aPresContext, PR_TRUE) == PR_FALSE) { aEventStatus = nsEventStatus_eIgnore; return NS_OK; diff --git a/layout/base/src/nsFrame.h b/layout/base/src/nsFrame.h index e0b9f76f296..928d54cee4e 100644 --- a/layout/base/src/nsFrame.h +++ b/layout/base/src/nsFrame.h @@ -265,7 +265,7 @@ protected: virtual void AdjustPointsInSameContent(nsIPresContext& aPresContext, nsGUIEvent * aEvent); - PRBool DisplaySelection(nsIPresContext& aPresContext); + PRBool DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn = PR_FALSE); // Style post processing hook NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);