Fixed the release problem on shell and doc and added a default paramenter to

Display Selection
This commit is contained in:
rods%netscape.com 1998-08-03 23:39:16 +00:00
Родитель 231d5b637d
Коммит d2d63295af
2 изменённых файлов: 23 добавлений и 10 удалений

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

@ -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(); PRBool result = PR_FALSE;
nsIDocument *doc = shell->GetDocument();
PRBool result = doc->GetDisplaySelection(); nsIPresShell *shell = aPresContext.GetShell();
NS_RELEASE(shell); if (nsnull != shell) {
NS_RELEASE(doc); 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; return result;
} }
@ -558,8 +568,11 @@ NS_METHOD nsFrame::HandleEvent(nsIPresContext& aPresContext,
mContent->HandleDOMEvent(aPresContext, (nsEvent*)aEvent, nsnull, DOM_EVENT_INIT, aEventStatus); mContent->HandleDOMEvent(aPresContext, (nsEvent*)aEvent, nsnull, DOM_EVENT_INIT, aEventStatus);
} }
if (DisplaySelection(aPresContext) == PR_FALSE) if (DisplaySelection(aPresContext) == PR_FALSE) {
return NS_OK; if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) {
return NS_OK;
}
}
if(nsEventStatus_eIgnore == aEventStatus) { if(nsEventStatus_eIgnore == aEventStatus) {
if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection || if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection ||
@ -597,7 +610,7 @@ NS_METHOD nsFrame::HandlePress(nsIPresContext& aPresContext,
nsEventStatus& aEventStatus, nsEventStatus& aEventStatus,
nsFrame * aFrame) nsFrame * aFrame)
{ {
if (DisplaySelection(aPresContext) == PR_FALSE) if (DisplaySelection(aPresContext, PR_TRUE) == PR_FALSE)
{ {
aEventStatus = nsEventStatus_eIgnore; aEventStatus = nsEventStatus_eIgnore;
return NS_OK; return NS_OK;

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

@ -265,7 +265,7 @@ protected:
virtual void AdjustPointsInSameContent(nsIPresContext& aPresContext, virtual void AdjustPointsInSameContent(nsIPresContext& aPresContext,
nsGUIEvent * aEvent); nsGUIEvent * aEvent);
PRBool DisplaySelection(nsIPresContext& aPresContext); PRBool DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn = PR_FALSE);
// Style post processing hook // Style post processing hook
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext); NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);